Live listeners
Get a document or a query's results, then every change to them as it happens: added, modified and removed.
A live listener is a query (or one document) that stays open. You get the current results first, then a snapshot with the changes every time a write affects them. Each listener sees only what its own user may read: the query re-runs as that user, with your collection rules and row policies.
const stop = await sov.collection('rooms/r1/messages')
.orderBy('at', 'desc').limit(50)
.onSnapshot((snap) => {
render(snap.docs)
for (const c of snap.changes) console.log(c.type, c.doc.id) // added | modified | removed
}, (err) => console.warn(err))
const stopDoc = await sov.doc('users/alice').onSnapshot((doc) => setProfile(doc.data))
stop(); stopDoc()#How it behaves
- Only the user who started a listener can subscribe to its channel, and nobody can publish on it.
- All of a client's listeners share one realtime connection: the JavaScript SDK sends a random per-client
client_channel, so tenonSnapshots are one WebSocket and one reconnect loop, and they are renewed in one request. The shared channel belongs to that client and its signed-in user only. - A listener doesn't run its query twice on start: once the connection is up, the SDK re-reads only if a change landed in between.
- Listeners expire after 10 minutes unless renewed; the SDKs renew every 5 minutes. Renewing checks the collection rules again, so revoked access stops within one renewal.
- After a reconnect, or when an update was missed, the SDKs re-run the query once and report the difference, so a snapshot never silently drifts.
- Writes to collections nobody listens to cost nothing extra.
- Collection groups:
sov.collectionGroup('comments').onSnapshot(…)(or"collection_group": trueon_listen) listens to every collection with that id; documents are keyed by their full path, and each renewal re-checks the rules per collection pattern. - Each update is one realtime message and counts toward monthly realtime messages; listener channels don't count toward realtime channels.
#Plan limits
| Limit | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
Live listeners open at once (docs.max_listeners) | 100 | 2,000 | 10,000 | 25,000 | 100,000 |
Documents one listener tracks (docs.listener_max_docs) | 500 | 1,000 | 2,000 | 5,000 | 10,000 |
Over the cap, starting a listener returns 403 PLAN_LIMIT_REACHED.
#Coming from Firebase or Supabase?
| Platform | What this is called there |
|---|---|
| Firebase | Firestore onSnapshot listeners |
| Supabase | Supabase Realtime Postgres Changes |
| Sovaria | Live listeners |
Moving an existing app? Migrate from Supabase or Firebase imports users (with their passwords), data, files and rules.