Skip to main content

Introduction

Supabase Realtime allows you to listen to database changes, broadcast messages, track presence, and sync data across clients in real-time. It’s built on Phoenix Channels and WebSockets.

Features

Postgres Changes

Listen to INSERT, UPDATE, and DELETE operations on your database tables.

Broadcast

Send ephemeral messages between clients without persisting to the database.

Presence

Track and synchronize shared state between clients (like online users).

WebSocket Endpoint

Connect to the Realtime server:

Authentication

Authenticate using your API key and optional JWT token:

Channels

Channels are the foundation of Realtime. Create a channel to subscribe to changes:
string
required
Unique identifier for the channel.

Channel Lifecycle

Postgres Changes

Listen to database changes in real-time.

Listen to All Changes

string
required
The event type: INSERT, UPDATE, DELETE, or * for all.
string
required
The database schema (usually public).
string
required
The table name to listen to.

Payload Structure

string
The type of change: INSERT, UPDATE, or DELETE.
object
The new row data (for INSERT and UPDATE).
object
The old row data (for UPDATE and DELETE).
string
ISO 8601 timestamp of the change.

Listen to Specific Events

Filter Changes

Filter changes based on column values:
string
Filter expression in the format column=op.value.

Broadcast

Send and receive ephemeral messages between clients.

Send Messages

string
required
The event name for the broadcast.
object
required
The data to broadcast to other clients.

Receive Messages

Presence

Track which users are online and sync shared state.

Track Presence

object
required
The state to track for this client.

Listen to Presence

Presence Events

event
Fired when presence state is synchronized.
event
Fired when a new client joins the channel.
event
Fired when a client leaves the channel.

Multiple Listeners

Combine different listener types on a single channel:

Row Level Security

Realtime respects Row Level Security policies:
Only changes that the user has permission to see will be sent through Realtime.

Enable Realtime

Enable Realtime for a table:
Tables must have REPLICA IDENTITY FULL enabled to receive UPDATE and DELETE events with old values.

Connection Management

Connection States

Reconnection

The client automatically handles reconnection:

Rate Limiting

Realtime has built-in rate limiting:
  • Free tier: 200 concurrent connections, 10 events per second per channel
  • Pro tier: 500 concurrent connections, 100 events per second per channel
  • Enterprise: Custom limits

Best Practices

Always clean up subscriptions to prevent memory leaks:
Filter changes at the database level to reduce unnecessary data:
Handle connection errors gracefully:
Presence automatically handles disconnections and is ideal for online/offline status.

Limits and Quotas

Connection Limits

Message Size

  • Maximum payload size: 256 KB
  • Maximum channel name length: 255 characters

Next Steps

Channels

Learn about channel management

Subscriptions

Master subscription patterns