Platform
The connected platform client an app receives from connect. It hides the postMessage plumbing behind a promise/callback API: intents, events, surfaces, notifications, flags, modals, navigation, routing, and telemetry. Everything authorization-shaped here is advisory — the app’s backend remains the sole gate.
Properties
Section titled “Properties”readonly appId: string;This app’s id, as registered with the shell.
channelId
Section titled “channelId”readonly channelId: string;The shell-minted channel id for this connection.
config
Section titled “config”readonly config: Record<string, unknown>;Shell-supplied configuration for this app (e.g. feature profile, environment hints).
readonly flags: { get: Promise<T>; getAll: Promise<Record<string, boolean>>;};App-scoped feature flags, evaluated by the shell (advisory; an unknown key defaults off).
get<T>(key): Promise<T>;Read one flag’s value.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<T>
getAll()
Section titled “getAll()”getAll(): Promise<Record<string, boolean>>;Read all boolean flags.
Returns
Section titled “Returns”Promise<Record<string, boolean>>
initialRoute
Section titled “initialRoute”readonly initialRoute: string;The in-app subpath the shell asked the app to open on first render.
readonly modal: { open: Promise<T | null>;};Shell-brokered modals whose body is one of this app’s own surfaces.
open()
Section titled “open()”open<T>(opts): Promise<T | null>;Open the modal; resolves with the body’s result, or null if dismissed.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<T | null>
notify
Section titled “notify”readonly notify: { toast: Promise<void>;};Shell-owned notifications.
toast()
Section titled “toast()”toast(opts): Promise<void>;Show a toast.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
readonly route: { onShellNavigate: () => void; report: void;};Reconcile the app’s in-app routing with the shell.
onShellNavigate()
Section titled “onShellNavigate()”onShellNavigate(handler): () => void;React to a shell-initiated navigation within this app (no reload); returns an unsubscribe function.
Parameters
Section titled “Parameters”handler
Section titled “handler”Returns
Section titled “Returns”() => void
report()
Section titled “report()”report(subpath, opts?): void;Tell the shell the app’s internal route changed (updates the address bar). Default (false)
pushes a back-able history entry; { replace: true } replaces it (filters, tabs that should
not pollute the back stack). The shell ignores the echo of a navigation it just initiated.
Parameters
Section titled “Parameters”subpath
Section titled “subpath”string
replace?
Section titled “replace?”boolean
Returns
Section titled “Returns”void
session
Section titled “session”readonly session: Session;The user snapshot at connect time. Follow later changes via the session.changed event.
readonly state: StateClient;App-scoped shared state across this app’s frames (e.g. reflect a modal body’s live draft behind it). See StateClient.
telemetry
Section titled “telemetry”readonly telemetry: { error: void; event: void; timing: void;};Structured telemetry, correlated to the active trace.
error()
Section titled “error()”error(name, data?): void;Record a named error.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
event()
Section titled “event()”event(name, data?): void;Record a named event.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
timing()
Section titled “timing()”timing(name, data?): void;Record a named timing measurement.
Parameters
Section titled “Parameters”string
unknown
Returns
Section titled “Returns”void
readonly theme: ThemeInfo;The active theme. See ThemeInfo.
Methods
Section titled “Methods”disconnect()
Section titled “disconnect()”disconnect(): void;Detach all listeners and timers for this connection.
Returns
Section titled “Returns”void
embedSurface()
Section titled “embedSurface()”embedSurface(opts): SurfaceHandle;Embed another app’s live rendered surface inline in this app’s UI. The shell brokers a nested
provider iframe into opts.mount. Returns a SurfaceHandle to re-parameterise, size, or
close it.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”getRoles()
Section titled “getRoles()”getRoles(): string[];The user’s flat roles from the session, for AFFORDANCES — show/hide a control, decide whether to offer an embed. ADVISORY ONLY: a tampered value just changes what the client shows or attempts; the app’s backend independently introspects the live session and is the sole gate. Synchronous — a snapshot delivered in the handshake (refreshed on reconnect), not a round trip.
Returns
Section titled “Returns”string[]
hasRole()
Section titled “hasRole()”hasRole(role): boolean;Whether the advisory roles include role; for affordances only, never enforcement.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
invoke()
Section titled “invoke()”invoke<T>( intent, payload,options?): Promise<T>;Call an intent provided by some other app, brokered by the shell; rejects with a PlatformError on failure.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”intent
Section titled “intent”string
payload
Section titled “payload”unknown
options?
Section titled “options?”Returns
Section titled “Returns”Promise<T>
log( level, message, fields?): void;Emit a structured, trace-correlated log line (stamped with the app id, trace id, and timestamp,
collected in the shell-side log buffer). fields must be structured-clone serializable — a
non-clonable value throws synchronously here, exactly like invoke/publish (it is NOT raw console).
Parameters
Section titled “Parameters”message
Section titled “message”string
fields?
Section titled “fields?”Record<string, unknown>
Returns
Section titled “Returns”void
navigate()
Section titled “navigate()”navigate(opts): Promise<void>;Ask the shell to change the top-level location. See NavigateOptions.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
onThemeChange()
Section titled “onThemeChange()”onThemeChange(handler): () => void;Subscribe to theme changes; returns an unsubscribe function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(theme) => void
Returns
Section titled “Returns”() => void
provide()
Section titled “provide()”provide<P>( intent, version, handler): () => void;Register a handler for an intent this app provides; returns an unregister function.
Type Parameters
Section titled “Type Parameters”P = unknown
Parameters
Section titled “Parameters”intent
Section titled “intent”string
version
Section titled “version”string
handler
Section titled “handler”Returns
Section titled “Returns”() => void
publish()
Section titled “publish()”publish(topic, payload): void;Broadcast an ambient event (fan-out, no response).
Parameters
Section titled “Parameters”string
payload
Section titled “payload”unknown
Returns
Section titled “Returns”void
ready()
Section titled “ready()”ready(): void;Signal the app has finished bootstrapping and registered its handlers — the shell holds
intent/navigation/event traffic until this is sent. Call once, after provide / subscribe /
onShellNavigate are wired.
Returns
Section titled “Returns”void
span()
Section titled “span()”span(name): SpanHandle;Open a manual span under the current trace’s active span, for timing app-side work the shell
can’t observe. Rarely needed — the SDK already auto-spans provide handlers. Close the handle to
record it. See SpanHandle.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”subscribe()
Section titled “subscribe()”subscribe<P>(topic, handler): () => void;Listen for a broadcast event; returns an unsubscribe function.
Type Parameters
Section titled “Type Parameters”P = unknown
Parameters
Section titled “Parameters”string
handler
Section titled “handler”EventHandler<P>
Returns
Section titled “Returns”() => void