The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
realtime: Add settings documentation (#37182)
Filipe Cabaço29756da21f85
diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdxindex 3dce5b919f7..66c854efcb7 100644--- a/apps/docs/content/guides/realtime/authorization.mdx+++ b/apps/docs/content/guides/realtime/authorization.mdx@@ -18,6 +18,12 @@ Realtime Authorization is in Public Beta. To use Authorization for your Realtime</Admonition>+<Admonition type="note">++To enforce private channels you need to disable the 'Allow public access' setting in [Realtime Settings](https://supabase.com/dashboard/project/_?featurePreviewModal=supabase-ui-realtime-settings)++</Admonition>+## How it worksRealtime uses the `messages` table in your database's `realtime` schema to generate access policies for your clients when they connect to a Channel topic.diff --git a/apps/docs/content/guides/realtime/concepts.mdx b/apps/docs/content/guides/realtime/concepts.mdxindex 867a53f4a05..79ea841817d 100644--- a/apps/docs/content/guides/realtime/concepts.mdx+++ b/apps/docs/content/guides/realtime/concepts.mdx@@ -26,6 +26,18 @@ const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>'const roomOne = supabase.channel('room-one') // set your topic here```+## Authorization++Authorization is done via RLS policies against the table `realtime.messages` which will determine if a user can connect to a Channel and if they are allowed to send messages to a Channel.++By default, channels are public and you need to set that you want to use a private channel.++```js+import { createClient } from '@supabase/supabase-js'+const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>')+const roomOne = supabase.channel('private-room-one', { config: { private: true } })+```+## BroadcastRealtime Broadcast follows the [publish-subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) where a client publishes messages to a channel based on a unique topic. For example, a user could send a message to a channel with topic `room-one`.@@ -45,6 +57,8 @@ roomOne.send({Other clients can receive the message in real-time by subscribing to the Channel with topic `room-one`. These clients continue to receive messages as long as they are subscribed and connected to the same Channel topic.+You can also use [Broadcast using the REST API](/docs/guides/realtime/broad cast#broadcast-using-the-rest-api) and [Broadcast using the Database](/docs/guides/realtime/broadcast#broadcast-using-the-database) to send messages to a Channel which allows you to do more advanced use-cases.+An example use-case is sharing a user's cursor position with other clients in an online game.## Presence@@ -93,6 +107,36 @@ Anyone with access to a valid JWT signed with the project's JWT secret is able tClients can choose to receive `INSERT`, `UPDATE`, `DELETE`, or `*` (all) changes for all changes in a schema, a table in a schema, or a column's value in a table. Your clients should only listen to tables in the `public` schema and you must first enable the tables you want your clients to listen to.+## Settings++<Admonition type="note">++Realtime settings are currently under Feature Preview section in the dashboard.++</Admonition>++<Image+ alt="Usage page navigation bar"+ src={{+ light: '/docs/img/guides/platform/realtime-settings--light.png',+ dark: '/docs/img/guides/platform/realtime-settings--dark.png',+ }}+ zoomable+/>++You can set the following settings using the Realtime Settings screen in your Dashboard:++- Channel Restrictions: You can toggle this settings to set Realtime to allow public channels or set it to use only private channels with [Realtime Authorization](/docs/content/guides/realtime/authorization).+- Database connection pool size: Determines the number of connections used for Realtime Authorization RLS checking+ {/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}+- Max concurrent clients: Determines the maximum number of clients that can be connected++All changes made in this screen will disconnect all your connected clients to ensure Realtime starts with the appropriate settings and all changes are stored in Supabase middleware.++## Choosing between Broadcast and Postgres Changes for database changes++We recommend using Broadcast by default and using Broadcast from Database specifically as it will allow you to scale your application compared to Postgres Changes.+## Choosing between Broadcast and PresenceWe recommend using Broadcast by default, and then Presence when required. Presence utilizes an in-memory conflict-free replicated data type (CRDT) to track and synchronize shared state in an eventually consistent manner. It computes the difference between existing state and new state changes and sends the necessary updates to clients via Broadcast. This is computationally heavy, so you should use it sparingly. If you use Presence, it's best to throttle your changes so that you are sending updates less frequently.diff --git a/apps/docs/public/img/guides/platform/realtime-settings--dark.png b/apps/docs/public/img/guides/platform/realtime-settings--dark.pngnew file mode 100644index 00000000000..b9ee8747b55Binary files /dev/null and b/apps/docs/public/img/guides/platform/realtime-settings--dark.png differdiff --git a/apps/docs/public/img/guides/platform/realtime-settings--light.png b/apps/docs/public/img/guides/platform/realtime-settings--light.pngnew file mode 100644index 00000000000..3587df9ebd2Binary files /dev/null and b/apps/docs/public/img/guides/platform/realtime-settings--light.png differ