API Reference

Key exports and types from @constela/runtime

Key Exports

ExportDescription
createAppCreates an application instance
mountMounts the app to a DOM element
hydrateHydrates server-rendered HTML

createApp

Creates a new Constela application instance:

typescript
function createApp(program: CompiledProgram): App;

mount

Mounts an application to a DOM element:

typescript
function mount(app: App, container: HTMLElement): void;

hydrate

Hydrates a server-rendered application:

typescript
function hydrate(app: App, container: HTMLElement): void;

App Interface

typescript
interface App {
  destroy(): void;
  getState(): Record<string, unknown>;
  dispatch(action: string, payload?: unknown): void;
}