Skip to content

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.

readonly appId: string;

This app’s id, as registered with the shell.


readonly channelId: string;

The shell-minted channel id for this connection.


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.

T = unknown

string

Promise<T>

getAll(): Promise<Record<string, boolean>>;

Read all boolean flags.

Promise<Record<string, boolean>>


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<T>(opts): Promise<T | null>;

Open the modal; resolves with the body’s result, or null if dismissed.

T = unknown

ModalOpenOptions

Promise<T | null>


readonly notify: {
toast: Promise<void>;
};

Shell-owned notifications.

toast(opts): Promise<void>;

Show a toast.

ToastOptions

Promise<void>


readonly route: {
onShellNavigate: () => void;
report: void;
};

Reconcile the app’s in-app routing with the shell.

onShellNavigate(handler): () => void;

React to a shell-initiated navigation within this app (no reload); returns an unsubscribe function.

ShellNavigateHandler

() => void

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.

string

boolean

void


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.


readonly telemetry: {
error: void;
event: void;
timing: void;
};

Structured telemetry, correlated to the active trace.

error(name, data?): void;

Record a named error.

string

unknown

void

event(name, data?): void;

Record a named event.

string

unknown

void

timing(name, data?): void;

Record a named timing measurement.

string

unknown

void


readonly theme: ThemeInfo;

The active theme. See ThemeInfo.

disconnect(): void;

Detach all listeners and timers for this connection.

void


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.

EmbedSurfaceOptions

SurfaceHandle


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.

string[]


hasRole(role): boolean;

Whether the advisory roles include role; for affordances only, never enforcement.

string

boolean


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.

T = unknown

string

unknown

InvokeOptions

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).

LogLevel

string

Record<string, unknown>

void


navigate(opts): Promise<void>;

Ask the shell to change the top-level location. See NavigateOptions.

NavigateOptions

Promise<void>


onThemeChange(handler): () => void;

Subscribe to theme changes; returns an unsubscribe function.

(theme) => void

() => void


provide<P>(
intent,
version,
handler): () => void;

Register a handler for an intent this app provides; returns an unregister function.

P = unknown

string

string

IntentHandler<P>

() => void


publish(topic, payload): void;

Broadcast an ambient event (fan-out, no response).

string

unknown

void


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.

void


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.

string

SpanHandle


subscribe<P>(topic, handler): () => void;

Listen for a broadcast event; returns an unsubscribe function.

P = unknown

string

EventHandler<P>

() => void