Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs(realtime): restructure

Greg Richardson093186c4ce89
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index fac3fe91346..b1cbef6f9b4 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -792,6 +792,10 @@ export const realtime: NavMenuConstant = {
name: 'Overview',
url: '/guides/realtime',
},
+ {
+ name: 'Concepts',
+ url: '/guides/realtime/concepts',
+ },
{
name: 'Quickstart',
url: '/guides/realtime/quickstart',
@@ -800,18 +804,11 @@ export const realtime: NavMenuConstant = {
name: 'Features',
url: undefined,
items: [
- { name: 'Channels', url: '/guides/realtime/channels' },
+ { name: 'Broadcast', url: '/guides/realtime/extensions/broadcast' },
+ { name: 'Presence', url: '/guides/realtime/extensions/presence' },
{
- name: 'Extensions',
- url: '/guides/realtime/extensions',
- items: [
- { name: 'Broadcast', url: '/guides/realtime/extensions/broadcast' },
- { name: 'Presence', url: '/guides/realtime/extensions/presence' },
- {
- name: 'Postgres Changes',
- url: '/guides/realtime/extensions/postgres-changes',
- },
- ],
+ name: 'Postgres Changes',
+ url: '/guides/realtime/extensions/postgres-changes',
},
],
},
diff --git a/apps/docs/pages/guides/realtime/architecture.mdx b/apps/docs/pages/guides/realtime/architecture.mdx
index 5a4173bdb88..ff43225cc60 100644
--- a/apps/docs/pages/guides/realtime/architecture.mdx
+++ b/apps/docs/pages/guides/realtime/architecture.mdx
@@ -21,6 +21,12 @@ Phoenix can handle many concurrent connections because Elixir provides lightweig
Client-facing WebSocket servers need to handle many concurrent connections. Elixir & Phoenix let the Supabase Realtime cluster do this easily.
+## Channels
+
+Channels are implemented using [Phoenix Channels](https://hexdocs.pm/phoenix/channels.html) which uses [Phoenix.PubSub](https://hexdocs.pm/phoenix_pubsub/Phoenix.PubSub.html) with the default `Phoenix.PubSub.PG2` adapter.
+
+The PG2 adapter utilizes Erlang [process groups](https://www.erlang.org/docs/18/man/pg2.html) to implement the PubSub model where a publisher can send messages to many subscribers.
+
## Global Cluster
Presence is an in-memory key-value store backed by a CRDT. When a user is connected to the cluster the state of that user is sent to all connected Realtime nodes.
diff --git a/apps/docs/pages/guides/realtime/channels.mdx b/apps/docs/pages/guides/realtime/channels.mdx
deleted file mode 100644
index b016f4bf6f6..00000000000
--- a/apps/docs/pages/guides/realtime/channels.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- id: 'channels',
- title: 'Realtime Channels',
- description: 'WebSockets are Channels on Supabase Realtime',
- sidebar_label: 'Channels',
-}
-
-You can uniquely reference a channel by its `topic` you define when you initialize your Supabase Realtime client. Everyone connected to the same Channel topic will receive the same messages.
-
-Clients can send and receive messages bi-directionally over a Channel. The Realtime backend can also push messages to all clients connected to the same Channel.
-
-A single client can receive change records from Postgres, Broadcast messages from other clients and Presence updates all over the same Channel.
-
-Channels are implemented over [Phoenix Channels](https://hexdocs.pm/phoenix/channels.html) which uses [Phoenix.PubSub](https://hexdocs.pm/phoenix_pubsub/Phoenix.PubSub.html) with the default `Phoenix.PubSub.PG2` adapter.
-
-The PG2 adapter utilizes Erlang [process groups](https://www.erlang.org/docs/18/man/pg2.html) to implement the PubSub model where a publisher can send messages to many subscribers.
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/realtime/concepts.mdx b/apps/docs/pages/guides/realtime/concepts.mdx
new file mode 100644
index 00000000000..6db5b9f5f9e
--- /dev/null
+++ b/apps/docs/pages/guides/realtime/concepts.mdx
@@ -0,0 +1,38 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'channels',
+ title: 'Realtime Concepts',
+ description: 'Learn about channels and other features in Supabase Realtime',
+ sidebar_label: 'Concepts',
+}
+
+Supabase Realtime lets you to build real-time applications with collaborative/multiplayer functionality. It includes 3 core features:
+
+- [Broadcast](/docs/guides/realtime/broadcast): sends rapid, ephemeral messages to other connected clients. You can use it to track mouse movements, for example.
+- [Presence](/docs/guides/realtime/presence): sends user state between connected clients. You can use it to show an "online" status, which disappears when a user is disconnected.
+- [Postgres Changes](/docs/guides/realtime/postgres-changes): receives database changes in real-time.
+
+## Channels
+
+When you initialize your Supabase Realtime client, you define a `topic` that uniquely references a channel. Everyone connected to the same Channel `topic` receives the same messages.
+
+```js
+const { createClient } = require('@supabase/supabase-js')
+
+const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)
+
+const channel = supabase.channel('my-topic') // set your topic here
+```
+
+Clients can bi-directionally send and receive messages over a Channel. The Realtime backend can also push messages to all clients connected to the same Channel.
+
+A single client can receive change records from Postgres, Broadcast messages from other clients, and Presence updates all over the same Channel.
+
+## Choosing between Broadcast and Presence
+
+We recommend using Broadcast by default, and then Presence when required. Presence merges all changes into a shared state for every client connected to the same channel. If you use Presence, it's best to throttle your changes so that you are sending updates less frequently.
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/realtime/extensions.mdx b/apps/docs/pages/guides/realtime/extensions.mdx
deleted file mode 100644
index 3f9db9c4702..00000000000
--- a/apps/docs/pages/guides/realtime/extensions.mdx
+++ /dev/null
@@ -1,27 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- id: 'extensions',
- title: 'Realtime Extensions',
- description:
- 'Extensions enable powerful Realtime features like Presence, Broadcast and database change streaming',
- sidebar_label: 'Extensions',
-}
-
-Supabase Realtime provides multiplayer features so that you can build real-time applications. The server has several built-in extensions to solve specific tasks.
-
-- [Broadcast](/docs/guides/realtime/broadcast): for sending rapid, ephemeral messages to other connected clients. A typical use-case is tracking mouse movements.
-- [Presence](/docs/guides/realtime/presence): for sending user state between connected clients. A typical use-case is simply an "online" status, which will disappear when a user is disconnected.
-- [Postgres Changes](/docs/guides/realtime/postgres-changes): for receiving database changes in real-time.
-
-## Choosing between Broadcast and Presence
-
-Defaulting to using Broadcast is a good idea, and then use Presence sparingly. The Presence extension merges all changes into a shared state for every client connected to the same "channel". If you _do_ use Presence, it's best to throttle your changes so that you are sending updates less frequently.
-
-## Future possibilities
-
-Realtime extensions are still under development. We have many more extensions planned. You can follow our progress by watching the [Realtime](https://github.com/supabase/realtime) repo on GitHub.
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/www/lib/redirects.js b/apps/www/lib/redirects.js
index a11a7dea2be..0f69f8d9667 100644
--- a/apps/www/lib/redirects.js
+++ b/apps/www/lib/redirects.js
@@ -2026,4 +2026,14 @@ module.exports = [
source: '/docs/guides/realtime/rate-limits',
destination: '/docs/guides/realtime/quotas',
},
+ {
+ permanent: true,
+ source: '/docs/guides/realtime/channels',
+ destination: '/docs/guides/realtime/concepts#channels',
+ },
+ {
+ permanent: true,
+ source: '/docs/guides/realtime/extensions',
+ destination: '/docs/guides/realtime/concepts',
+ },
]