Skip to content

Each host owns one id: one room, one thread, one session. Clients attach to it by URL, like /rooms/ab12. Whatever runs your hosts makes sure every client of an id reaches the same instance, and starts one when the first client arrives.

Clients attach by URL. A router sends every client of /rooms/ab12 to that room's host instance and every client of /rooms/cd34 to its own instance. Each instance owns its room's state.Clients of ab12Clients of cd34Routerone instance per id/rooms/ab12host instance/rooms/cd34host instancecd34ab12

Pick a runtime

RuntimePackageWhat you get
Cloudflare Durable Objects@statewire/cloudflareOne object per id, worldwide. Hibernating WebSockets, state saved to object storage.
Pinboard, in Pythonstatewire, pinnedOne object per id across your own workers. Restarts and deploys move objects without losing commands.
Your Node serverstatewire/host-internalA socket host you wire to any WebSocket or HTTP server, in a few lines.
The page itselfstatewireThe host runs next to the client. Good for tests, demos and offline-first apps.

The client doesn't change between them. Attach over WebSocket or over HTTP with server-sent events.

Cloudflare

A Durable Object is a natural Statewire host: one per id, single-threaded, with storage attached. statewireHandlers serves the WebSocket and HTTP routes and restores the state after the object wakes up. Riff runs every session this way.

Pinboard

In Python, a Statewire class is a Pinboard object. Pinboard places each id on one of your workers and moves it when a worker drains or dies. With a state store, admitted commands survive the move. Pinboard docs.

Your own server

StatewireSocketHost takes your host and speaks the protocol over any socket with send and close. Wire it to the WebSocket server you already run.

Hand this to your agent