Realtime
Channels with declarative access rules, presence, history, and automatic broadcasts on database changes.
Live data without polling
Codata Realtime gives every workspace multi-user subscriptions, presence, and message history over WebSockets. Channels are declared in your spec with access rules, and database changes can broadcast automatically — an order status change fans out to everyone watching that order, no polling loop needed.
Channels
Channels are name templates with declarative access rules:
{
"channels": [
{
"pattern": "order:{orderId}",
"access": { "subscribe": "end_user_match", "publish": "none" },
"presence": true,
"history": true
},
{
"pattern": "chat:{roomId}",
"access": { "subscribe": "authenticated", "publish": "authenticated" }
}
]
}public- Anyone can subscribe/publish — no auth needed.
authenticated- Any signed-in user of your app.
end_user_match- Only the end user the data belongs to — enforced via session claims.
none- Publish only — nobody can write (server-broadcast channels).
Database event bindings
Bind channels to data changes: pick an asset, the operations to watch, and which fields to include in the payload. When a record changes, subscribers get the event in real time.
{
"dbBindings": [
{
"assetName": "Order",
"operations": ["insert", "update"],
"channelTemplate": "order:{id}",
"event": "order.updated",
"payloadFields": ["id", "status"]
}
]
}Using realtime from the SDK
const rt = ws.realtime();
// Client-side: connect & subscribe
const conn = await rt.connect({ endUserId: user.id });
const sub = await conn.subscribe("order:12345");
sub.on("order.updated", (msg) => updateUi(msg.payload));
sub.on("*", (msg) => console.log("any event", msg));
// Server-side: publish to subscribers
await rt.publish("order:12345", "order.updated", { id, status: "shipped" });
// Presence: who's here right now
const presence = await rt.presence("order:12345");Presence, history & limits
- Presence — see who's connected to a channel (great for "3 people viewing").
- History — channels with history replay recent messages on subscribe and recover missed messages after reconnects.
- Limits — per-connection message rate, max payload size, and retention days are configurable per workspace.
- Webhooks — channel events can optionally fan out to external HTTPS endpoints.
Channels are private by default — nothing is subscribable unless a pattern explicitly allows it. Branch isolation is enforced at the connection-token level, so a staging branch can never leak into production channels.