Krizaka
Documentation
Tooling

Realtime

The server bus and presence behind live screens: memory, PostgreSQL or Redis, delivered over SSE.

@krizaka/realtime gives a Node app realtime behind one interface: a bus (publish and subscribe by channel), presence (who is connected, by heartbeat and time-to-live) and Server-Sent Events. The adapter is a deployment choice — memory, PostgreSQL LISTEN/NOTIFY or Redis / Valkey — and the code that publishes and subscribes never knows which.

npm install @krizaka/realtime
npm install pg        # for the PostgreSQL adapter (optional)
npm install ioredis   # for the Redis / Valkey adapter (optional)
EntryWhat
@krizaka/realtimeRealtimeBus, PresenceStore, createBus, memoryBus, postgresBus, eventStream, sseFrame. No driver is loaded.
@krizaka/realtime/pgpgChannel: the PostgreSQL channel, on node-postgres.
@krizaka/realtime/redisredisBus and RedisPresence.

The contract

  • Best-effort. publish never throws. A durable fact (a message, a bid) lives in the database and is replayed from it — never from the bus.
  • Small payloads. Ids and small facts; a PostgreSQL NOTIFY is capped at 8 000 bytes.
  • Presence is never a database write per beat. A closed connection lingers briefly so a reconnection changes nothing.
  • Fail loudly on configuration. createBus refuses a bus that cannot work instead of falling back to memory.

On the client, @krizaka/query invalidates what an event touched, so a screen stays live without polling.

On this page