Version: Next
About
Introduction
The easiest way to get started with Realtime is to sign up to our Alpha.
If you want to host your own Realtime server, this document will help you to get set up. You have options to host using Docker, AWS, DigitalOcean, or build from source.
Prerequisites
- Postgres 10+
- Environment variables to set:
DB_HOST
: defaults tolocalhost
DB_NAME
: defaults topostgres
DB_USER
: defaults topostgres
DB_PASSWORD
: defaults topostgres
DB_PORT
: defaults to5432
Setting Up Replication
For us to receive the streaming data, we need the database to have a free replication slot:
-- set the replication to "logical"
ALTER SYSTEM SET wal_level = logical;
-- We need at least one replication slot to subscribe to
ALTER SYSTEM SET max_replication_slots = 5;
-- Set up the publication for us to listen to
CREATE PUBLICATION supabase_realtime FOR ALL TABLES;
Optional
If you want to receive the old record (previous values) on UPDATE
and DELETE
, you can set the REPLICA IDENTITY
to FULL
like this:
ALTER TABLE your_table REPLICA IDENTITY FULL;
This has to be set for each table.