diff --git a/web/docs/hosting/realtime.mdx b/web/docs/hosting/realtime.mdx new file mode 100644 index 00000000000..8bbc55f7895 --- /dev/null +++ b/web/docs/hosting/realtime.mdx @@ -0,0 +1,37 @@ +--- +id: hosting-realtime +title: Self-hosting Supabase Realtime +--- + +## Pre-requisites + +- Postgres 10+ + +## What you will need + +- `DB_HOST`: defaults to `localhost` +- `DB_NAME`: defaults to `postgres` +- `DB_USER`: defaults to `postgres` +- `DB_PASSWORD`: defaults to `postgres` +- `DB_PORT`: defaults to `5432` + + +## Setting up replication + +For us to receive the streaming data, we need the database to have a free replication slot: + +```sql +ALTER SYSTEM SET wal_level = logical; -- set the replication to "logical" +ALTER SYSTEM SET max_replication_slots = 5; -- We need at least one replication slot to subscribe to +CREATE PUBLICATION supabase_realtime FOR ALL TABLES; -- Set up the publication for us to listen to +``` + +### Optional + +If you want to recieve the old record (previous values) on `UDPATE` and `DELETE`, you can set the `REPLICA IDENTITY` to `FULL` like this: + +```sql +ALTER TABLE your_table SET REPLICA IDENTITY = FULL; +``` + +This has to be set for each table unfortunately. \ No newline at end of file diff --git a/web/docusaurus.config.js b/web/docusaurus.config.js index 795d8f70e15..146751bb732 100755 --- a/web/docusaurus.config.js +++ b/web/docusaurus.config.js @@ -72,6 +72,10 @@ module.exports = { label: 'GitHub', href: 'https://github.com/supabase/monorepo', }, + { + label: 'Twitter', + href: 'https://twitter.com/supabase_io', + }, // { // label: "Discord", // href: "https://discordapp.com/invite/docusaurus" diff --git a/web/sidebars.js b/web/sidebars.js index 4bf323db514..4a44c5abf3a 100755 --- a/web/sidebars.js +++ b/web/sidebars.js @@ -26,6 +26,9 @@ module.exports = { Handbook:[ "handbook/introduction", "handbook/contributing" + ], + 'Self Hosting':[ + "hosting/hosting-realtime" ] } };