Goal
Connect a browser application directly to the iii engine over WebSocket so frontend code can call backend functions and receive live invocations — without HTTP endpoints in between.Why the browser SDK instead of HTTP calls
With a traditional HTTP setup, every interaction follows the same pattern: the browser sends a request, waits for a response, and repeats. Real-time features require polling or bolting on a separate WebSocket layer. The browser SDK turns your frontend into a first-class iii worker:- Persistent connection — one WebSocket replaces many HTTP round-trips. No per-request handshake, no CORS preflight on every call.
- Bi-directional — the engine can invoke functions registered in the browser. Backend workers push data to the frontend with
trigger(), enabling real-time patterns without polling. - Same API —
registerFunction,trigger,registerTrigger,onFunctionsAvailable— all the primitives you use server-side work identically in the browser. - Type-safe — the same TypeScript types (
ISdk,TriggerRequest,ApiRequest) are shared betweeniii-sdkandiii-sdk-browser.
Prerequisites
- A running iii engine with the WorkerModule enabled and RBAC configured (see Worker RBAC).
iii-sdk-browserinstalled in your frontend project.
Steps
1. Install the browser SDK
2. Enable the WorkerModule with RBAC
Browser workers connect through the RBAC port, not the internal bridge. Add aWorkerModule to your engine config:
iii-config.yaml
For production, add an
auth_function_id to validate tokens from the browser. See Worker RBAC for full auth setup.3. Connect from the browser
iii.ts
4. Register functions and triggers
app.ts
Example: Real-time dashboard
A metrics dashboard that updates instantly when backend data changes — no polling. Backend worker registers a function that pushes metrics to all browser workers:metrics-worker.ts
dashboard.tsx
setInterval polling GET /metrics every 5 seconds, getting stale data and wasting bandwidth when nothing changes. With iii, the backend pushes only when metrics actually update.
Example: Collaborative task board
A task board where multiple browser tabs see changes in real time — both reading and writing through iii. Backend worker handles task persistence:tasks-worker.ts
task-board.tsx
ui::tasks-updated function fires instantly.
Result
Your browser is a full iii worker. It registers functions, calls backend functions withtrigger(), and receives live invocations over a single WebSocket connection. No REST endpoints, no polling, no separate real-time layer.
The browser SDK exposes the same
ISdk interface as the Node SDK. See the Browser SDK Reference for the full API.