Skip to main content

Web host API

Quick reference​

APIBehavior
await ReloUI.create({wasmUrl})Initialize the shared Wasm engine.
RemoteDocument.create({source, data})Create source + optional data.
RemoteDocument.decode(json)Decode an envelope from JSON text after initializing the engine.
runtime.session(document)Validate and create RemoteSession.
runtime.action(name, {input, output}, operation)Register typed/validated host behavior.
runtime.binding(name, binding)Register a HostBinding.
runtime.mount(element, {session})Attach a DOM surface.
session.updateData(data)Replace root data and retain compatible state.
session.replace(document)Replace source and reset document lifetime.
session.onEvent / session.onErrorSubscribe to root output / diagnostics.
surface.setTheme(tokens)Replace host theme overrides while keeping the session mounted.
surface.dispose()Detach and remove the DOM, observers, component hosts, and resources.
session.close()Close logical state and cancel owned work.

Host capabilities​

runtime.navigation accepts open(request, context) and close(context), with optional supports(route) for preflight. Action and navigation handlers receive an AbortSignal through their context. runtime.component(name, definition) uses a PropsDecoder and an adapter factory. The registration can declare event(name), command(name, {input}, handler), and a child limit with children(maximum). Use an adapter's childrenHost to place rendered children. nativeProps and literal preserve the distinction between attribute literals and evaluated values.

ReloRuntime.create() and loadEngine(options) are available from @relo-ui/web/core. Engine initialization is shared within the loaded module. Use ReloUI.create({wasmUrl}) for DOM mounting. MountOptions also accepts sizing, theme, direction, tokens, imageLoader, imageAllowed, imageBaseUrl, and componentHosts. The session exposes motionPolicy and returns unsubscribe functions from onEvent, onError, and subscribe. RemoteSurface.detach() releases the session attachment. Call RemoteSurface.dispose() to free the surface when its host goes away.

Minimal host​

import {ReloUI, RemoteDocument} from '@relo-ui/web';
import wasmUrl from '@relo-ui/web/wasm?url';

const runtime = await ReloUI.create({wasmUrl});
const session = runtime.session(RemoteDocument.create({
source: '<Text text="Hello" />',
}));
const surface = runtime.mount(document.getElementById('screen')!, {session});
// On final disposal:
surface.dispose();
session.close();

Ownership and platform requirements​

Initialize and mount on the client. Serve Wasm with application/wasm and the required CSP/CORS. React hosting is optional through @relo-ui/react. Imports can be server-safe while live surfaces remain client-rendered.

Register actions, bindings, navigation, and native adapters before creating sessions. Session registrations are snapshotted. The app owns authentication, persistence, transport, and fallback UI. XML component definitions still need assembly even when Components host services are installed.

Web integration guide · Current source · Document contract