Realtime
Realtime for every project
Subscribe to database changes, broadcast low-latency messages between clients, and track who is online — over websockets, with Row Level Security deciding what each user receives.
stitchdb
.channel('todos')
.on('postgres_changes', { event: '*', schema: 'public', table: 'todos' }, (payload) => {
console.log(payload.eventType, payload.new)
})
.subscribe()What you get
Changes, broadcast and presence
Postgres changes
Add a table to the built-in stitchdb_realtime publication and receive inserts, updates and deletes.
Broadcast
Send ephemeral messages on channels — cursors, typing indicators, game state.
Presence
Track and sync who is connected with track() and presenceState().
How it works
Get started with Realtime
Publish a table
alter publication stitchdb_realtime add table public.todos;Subscribe
stitchdb.channel('todos').on('postgres_changes', …).subscribe()Send from SQL
select realtime.send('{"status":"shipped"}'::jsonb, 'order-update', 'orders', false);inside a trigger.
const room = stitchdb.channel('room-1')
room.on('broadcast', { event: 'cursor' }, ({ payload }) => moveCursor(payload))
await room.subscribe()
room.send({ type: 'broadcast', event: 'cursor', payload: { x: 120, y: 48 } })Example
See it in code
const room = stitchdb.channel('room-1')
room.on('broadcast', { event: 'cursor' }, ({ payload }) => moveCursor(payload))
await room.subscribe()
room.send({ type: 'broadcast', event: 'cursor', payload: { x: 120, y: 48 } })const room = stitchdb.channel('room-1')
room.on('presence', { event: 'sync' }, () => console.log(room.presenceState()))
room.subscribe(async (status) => {
if (status === 'SUBSCRIBED') await room.track({ user: 'ada', online_at: new Date().toISOString() })
})select realtime.send('{"status": "shipped"}'::jsonb, 'order-update', 'orders', false);Explore the platform
Start building on StitchDB today
Create your first project in under a minute.