Realtime
Subscribe to table changes, filter events, and use broadcast / presence channels.
Table changes
Enable realtime for a table in the dashboard Realtime page (installs a Postgres trigger), then subscribe with the anon key:
index.ts
const unsubscribe = voltbase.realtime.subscribe('products', (event) => {
console.log(event.type, event.table, event.record);
});
unsubscribe();
// or
voltbase.realtime.unsubscribe('products');
voltbase.realtime.disconnect();Filters
index.ts
voltbase.realtime.subscribe(
'products',
(event) => console.log(event.record),
{ event: 'INSERT', filter: { status: 'active' } },
);Broadcast & presence
index.ts
const channel = voltbase.realtime.channel('room-1');
channel
.on('broadcast', { event: 'cursor' }, ({ payload }) => {
console.log('cursor', payload);
})
.on('presence', { event: 'sync' }, ({ state }) => {
console.log('online', state);
})
.subscribe();
channel.send({ type: 'broadcast', event: 'cursor', payload: { x: 1, y: 2 } });
channel.track({ user: 'alice' });
channel.untrack();
channel.unsubscribe();Presence is single-instance
Presence state lives in memory on one API process. It does not sync across multiple Railway replicas — use one instance (or add Redis later) for shared presence.