Realtime
const unsubscribe = await cb.collection("posts").subscribe("*", (event) => { console.log(event.action, event.record); // "create" | "update" | "delete"});
// laterunsubscribe();topic is "*" (the whole collection) or a bare record id — matching
the topic grammar described in Realtime.
The third argument, SubscribeOptions (filter, fields, expand),
scopes the subscription server-side:
await cb.collection("posts").subscribe( "*", (event) => console.log(event.record.title), { filter: "published = true" },);No EventSource polyfill
Section titled “No EventSource polyfill”The SDK’s realtime transport is built on fetch and a streamed
ReadableStream response, not EventSource. That means:
- No polyfill needed in any environment
fetchruns in, including Node/SSR — subscriptions work outside the browser, unlikeEventSource, which is browser-only without a shim. - The stream carries whatever auth the client already uses — bearer
token or session cookie — since it’s an ordinary authenticated
fetchrequest, notEventSource’s cookie-only, header-less connection.
Subscriptions are still filtered server-side by the collection’s
listRule, so a subscriber never receives an event for a record it
couldn’t otherwise read.