Skip to content

Realtime rooms, without the plumbing

Three small, zero-dependency packages pulled out of a production realtime app — a WebSocket transport that survives deploys, and a state store you can test without a server.
$npm install @insession/space-state @insession/ws-resilient-transport

@insession/ws-resilient-transport

A WebSocket transport that reconnects the way a deploy actually needs it to: fast on a service restart, jittered exponential backoff otherwise, and a full stop on terminal close codes.

0 dependencies~130 LOC

@insession/space-state

A state store for shared rooms — members, chat, presence, plugins. Inbound messages fold through a pure reducer; side effects come back as descriptors instead of firing.

0 dependenciespure reducer

@insession/space-state-react

The React binding for space-state: one hook over useSyncExternalStore, about ten lines, no logic of its own.

1 hookreact peer

Only one edge between them: space-state-reactspace-state. ws-resilient-transport is independent — carrying bytes and holding state are kept apart on purpose, so you can adopt either one alone.

Nothing to install underneath

The transport and the store have zero runtime dependencies. No framework, no socket library, no DOM. That is the point of them, not an accident.

Testable without a server

The store takes plain objects in and hands plain descriptors back, so a full state transition is assertable in-process under node —test — no browser, no sockets, no wall-clock waits.

Shaped by real deploys

The reconnect behaviour exists because every client drops at the same instant on every deploy. Fast path on service restart, jitter so the fleet does not stampede, and a hard stop when the server says never again.