Realtime

Live data, straight from your database.

One WebSocket connection carries database changes, broadcast messages and presence. Private channels follow the same row-level security as your tables.

3
channel types
25 s
heartbeat interval
realtime.tsTS
import { createClient } from '@aurabase/aurabase-js'
const aura = createClient(
'https://my-project.aurabase.cloud',
'aura_anon_xxx',
)
aura
.channel('room')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'messages',
filter: 'room_id=eq.42',
},
(payload) => console.log(payload),
)
.subscribe()

What’s included

Everything that moves live. On one connection.

Database

Database changes

Subscribe to inserts, updates and deletes on a table as they happen.

Filters

Column filters

Receive only the rows you care about, such as room_id=eq.42. The server applies the filter before it sends the event.

Messaging

Broadcast

Send messages between clients on a channel, with optional server acknowledgement.

Presence

Who’s online

Track users on a channel and react when they join, leave or update their state.

Security

Private channels

Row-level security policies decide who can join a private channel, and are checked again when the token refreshes.

Security

Private-only projects

Require every channel of a project to be private, whatever the client asks for.

Server side

Broadcast over HTTP

Publish from a server or an edge function with one request.

Reliability

Automatic reconnection

A heartbeat detects dead connections, and the client reconnects with backoff and jitter, then re-subscribes its channels.

Observability

Clear connection and channel states

Follow the connection state, get transport errors with the phase that failed, and see why a channel was refused.

How it works

From a change to your screen.

  1. 1

    Connect

    The SDK opens one WebSocket with the user’s token.

  2. 2

    Subscribe

    Join a channel; the server checks access and confirms.

  3. 3

    Receive

    Database changes, broadcasts and presence arrive on that channel.

  4. 4

    Recover

    If the link drops, the SDK reconnects and re-subscribes.

Endpoints

Two routes. Everything else is a channel.

Send your project’s API key or the user’s token with each request.

MethodEndpointDescription
GET/v1/realtime/wsOpen the WebSocket connection. Channels are multiplexed over it.
POST/v1/realtime/broadcastSend a broadcast over HTTP, without a WebSocket.

Questions

Good to know.

How do I receive database changes?+
Subscribe to postgres_changes on a channel with the schema, table and event you want. Add a filter to receive only matching rows.
Who can see a private channel?+
Row-level security policies decide it from the user’s token when they subscribe. A token the policy refuses gets a channel error.
Can I send messages from my server?+
Yes. httpBroadcast() sends a broadcast over HTTP. Prefix the channel with your project ID when you call it without a user session.
What happens when the connection drops?+
The SDK reconnects automatically and re-subscribes your channels. Events sent while the connection was down are not guaranteed to be delivered, so re-read state you can’t afford to miss.
Why must I subscribe before sending?+
Access rules for a channel are computed when you subscribe. Sending on a channel you’re not subscribed to is refused, and the SDK reports it without sending anything.
Which events does a delete filter see?+
The old row. Which columns it carries depends on the table’s replica identity: the primary key by default, all columns with full replica identity.

Ready to go live?

Make your app react in real time.

Realtime is included in every project. No credit card required.