Realtime Overview
Live subscriptions and optimistic mutations via Zero
The SDK includes a realtime layer powered by Zero, a local-first sync engine. Use it when you need live-updating data or instant optimistic writes.
API surface
11 subscriptions and 20 optimistic mutations — same queries and mutations as the REST API, but with instant local updates and offline support.
One-shot reads
Use run() for a single read through the realtime layer. This waits for the
server to confirm the data is complete, then returns.
| Value | Behavior |
|---|---|
'complete' | Wait until server confirms all data is synced |
'lazy' | Resolve with whatever data is locally available |
When to use which
| Approach | Latency | Offline | Use case |
|---|---|---|---|
query.* | Server round-trip | No | Scripts, server-side, one-shot reads |
mutate.* | Server round-trip | No | Scripts, server-side, confirmed writes |
realtime.subscribe | Instant (local) | Yes | Live UI, dashboards, bots with presence |
realtime.mutate.* | Instant (local) | Yes | Interactive apps, chat UIs |
run() | Server-confirmed | No | One-shot reads that need freshness guarantee |