Events
Typed publishes, stored before they're delivered, replayed exactly after a drop.
An event is a name and JSON data, published to a channel. Every event gets the channel's next sequence number and is stored before anyone receives it, so delivery is in order, and a client that reconnects gets exactly what it missed, once.
Define a schema
One schema types your events (and presence) on the server and in the browser. Any Standard Schema library works: Zod, Valibot, ArkType. Without a schema, data is typed as JSON.
Publish from your server
Or over HTTP, from anything that can send a request:
Read in the browser
meta has the event's seq, its time ts, the publishing user (absent for server publishes) and replay, true while catching up. Without React, the client has the same thing:
Publish from the browser
A browser can publish to channels its token lists under `publish`. When the client has the schema, data is validated before it is sent; publishes made while offline are queued.
History and replay
- Live by default: a client receives events from the moment it joins.
history: truereplays everything the channel still keeps, then goes live. A number resumes after that sequence number.- A client that drops resumes from its last sequence number on its own, whether it was gone for three seconds or three hours.
Channels keep 24 hours of events by default. Set retention per channel, up to 7 days and 100,000 events, from your server or the dashboard:
Gaps
If a client was away longer than the channel keeps, it gets an explicit gap, never partial history, so your app can reload its state instead of showing a hole:
Your server can read history the same way. gap is true when since is older than what's kept; pass next as since to read on.
Limits
- Up to 1 MB of JSON per event.
- Event names use letters, digits and
_ - : ., likeorder.status.
Use events when every step matters and must arrive in order (orders, messages, strokes in a drawing). Use presence when only the newest value matters (cursors, who's typing).