Realtime
Use Realtime for transient coordination and refresh signals. PostgreSQL remains the durable source of truth.
js
const unsubscribe = await opencloud.realtime.subscribe(
"work-items",
({ event, payload }) => {
if (event === "changed") void refreshFromDatabase(payload);
},
);After a successful mutation:
js
await opencloud.realtime.publish("work-items", "changed", {
entity: "work-item",
id,
});The logical name must start with a lowercase letter and contain lowercase letters, numbers, or hyphens. The SDK adds the private app boundary and owns connection, heartbeat, session refresh, and reconnect behavior.
Call unsubscribe() during view teardown and opencloud.dispose() during app teardown. Never put secrets or full records in broadcast payloads; send identifiers and reload through RLS. Do not open WebSockets or construct Realtime protocol topics and envelopes yourself.
