The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix some typos; update passages to conform to style guide (#43254)
Kevin Strong-Holte732180608a03
diff --git a/apps/docs/content/guides/realtime/broadcast.mdx b/apps/docs/content/guides/realtime/broadcast.mdxindex 7fd48580d3e..9d740fcbd06 100644--- a/apps/docs/content/guides/realtime/broadcast.mdx+++ b/apps/docs/content/guides/realtime/broadcast.mdx@@ -10,22 +10,22 @@ You can use Realtime Broadcast to send low-latency messages between users. MessaThe way Broadcast works changes based on the channel you are using:-- From REST API will receive an HTTP request which then will be sent via WebSocket to connected clients-- From Client libraries we have an established WebSocket connection and we use that to send a message to the server which then will be sent via WebSocket to connected clients-- From Database we add a new entry to `realtime.messages` where we have logical replication set to listen for changes which then will be sent via WebSocket to connected clients+- **REST API**: Receives an HTTP request and then sends a message via WebSocket to connected clients+- **Client libraries**: Sends a message via WebSocket to the server, and then the server sends a message via WebSocket to connected clients+- **Database**: Adds a new entry to `realtime.messages` where a logical replication is set to listen for changes, and then sends a message via WebSocket to connected clients<Admonition type="note">-The public flag (the last argument in `realtime.send(payload, event, topic, is_private))` only affects who can subscribe to the topic not who can read messages from the database.+The public flag (the last argument in `realtime.send(payload, event, topic, is_private)`) only affects who can subscribe to the topic not who can read messages from the database.-- Public (false) → Anyone can subscribe to that topic without authentication-- Private (true) → Only authenticated clients can subscribe to that topic+- Public (`false`) → Anyone can subscribe to that topic without authentication+- Private (`true`) → Only authenticated clients can subscribe to that topic-However, regardless of whether it's public or private, the Realtime service connects to your database as the authenticated Supabase Admin role.+Regardless if it's public or private, the Realtime service connects to your database as the authenticated Supabase Admin role.</Admonition>-For Authorization we insert a message and try to read it, and rollback the transaction to verify that the RLS policies set by the user are being respected by the user joining the channel, but this message isn't sent to the user. You can read more about it in the [Authorization docs](/docs/guides/realtime/authorization).+For Authorization, we insert a message and try to read it, and rollback the transaction to verify that the Row Level Security (RLS) policies set by the user are being respected by the user joining the channel, but this message isn't sent to the user. You can read more about it in [Authorization](/docs/guides/realtime/authorization).## Subscribe to messages@@ -132,9 +132,9 @@ In most cases, you can get the correct key from [the Project's **Connect** dialo</$Show></Tabs>-### Receiving Broadcast messages+### Receive Broadcast messages-You can provide a callback for the `broadcast` channel to receive messages. This example will receive any `broadcast` messages that are sent to `test-channel`:+You can receive Broadcast messages by providing a callback to the channel.<Tabsscrollable@@ -448,13 +448,13 @@ select<Admonition type="note">-The realtime.send function in the database includes a flag that determines whether the broadcast is private or public, and client channels also have the same configuration. For broadcasts to work correctly, these settings must match a public broadcast will only reach public channels, and a private broadcast will only reach private ones.+The `realtime.send()` function in the database includes a flag that determines whether the broadcast is private or public, and client channels also have the same configuration. For broadcasts to work correctly, these settings must match. A public broadcast only reaches public channels and a private broadcast only reaches private channels.-By default, all database broadcasts are private, meaning clients must authenticate to receive them. If the database sends a public message but the client subscribes to a private channel, the message won't be delivered since private channels only accept signed, authenticated messages.+By default, all database broadcasts are private, meaning clients must authenticate to receive them. If the database sends a public message but the client subscribes to a private channel, the message is not delivered because private channels only accept signed, authenticated messages.</Admonition>-It's a common use case to broadcast messages when a record is created, updated, or deleted. We provide a helper function specific to this use case, `realtime.broadcast_changes()`. For more details, check out the [Subscribing to Database Changes](/docs/guides/realtime/subscribing-to-database-changes) guide.+You can use the `realtime.broadcast_changes()` helper function to broadcast messages when a record is created, updated, or deleted. For more details, read [Subscribing to Database Changes](/docs/guides/realtime/subscribing-to-database-changes).### Broadcast using the REST API@@ -685,7 +685,7 @@ You can pass configuration options while initializing the Supabase Client.><TabPanel id="js" label="JavaScript">- You can confirm that the Realtime servers have received your message by setting Broadcast's `ack` config to `true`.+ You can confirm that the Realtime servers have received your message by setting Broadcast's `ack` setting to `true`.{/* prettier-ignore */}```js@@ -881,20 +881,20 @@ You can also send a Broadcast message by making an HTTP request to Realtime serv### How it works-Broadcast Changes allows you to trigger messages from your database. To achieve it Realtime is directly reading your WAL (Write Append Log) file using a publication against the `realtime.messages` table so whenever a new insert happens a message is sent to connected users.+Broadcast Changes allows you to trigger messages from your database. To achieve it, Realtime directly reads your Write-Ahead Log (WAL) file using a publication against the `realtime.messages` table. Whenever a new insert occurs, a message is sent to connected users.-It uses partitioned tables per day which allows the deletion your previous messages in a performant way by dropping the physical tables of this partitioned table. Tables older than 3 days old are deleted.+It uses partitioned tables per day, which allows performant deletion of your previous messages by dropping the physical tables of this partitioned table. Tables older than 3 days are deleted.-Broadcasting from the database works like a client-side broadcast, using WebSockets to send JSON packages. [Realtime Authorization](/docs/guides/realtime/authorization) is required and enabled by default to protect your data.+Broadcasting from the database works like a client-side broadcast, using WebSockets to send JSON payloads. [Realtime Authorization](/docs/guides/realtime/authorization) is required and enabled by default to protect your data.-The database broadcast feature provides two functions to help you send messages:+Broadcast Changes provides two functions to help you send messages:-- `realtime.send` will insert a message into realtime.messages without a specific format.-- `realtime.broadcast_changes` will insert a message with the required fields to emit database changes to clients. This helps you set up triggers on your tables to emit changes.+- `realtime.send()` inserts a message into `realtime.messages` without a specific format.+- `realtime.broadcast_changes()` inserts a message with the required fields to emit database changes to clients. This helps you set up triggers on your tables to emit changes.### Broadcasting a message from your database-The `realtime.send` function provides the most flexibility by allowing you to broadcast messages from your database without a specific format. This allows you to use database broadcast for messages that aren't necessarily tied to the shape of a Postgres row change.+The `realtime.send()` function provides the most flexibility by allowing you to broadcast messages from your database without a specific format. This allows you to use database broadcast for messages that aren't necessarily tied to the shape of a Postgres row change.```sqlSELECT realtime.send (@@ -909,7 +909,7 @@ SELECT realtime.send (#### Setup realtime authorization-Realtime Authorization is required and enabled by default. To allow your users to listen to messages from topics, create an RLS (Row Level Security) policy:+Realtime Authorization is required and enabled by default. To allow your users to listen to messages from topics, create an RLS policy:```sqlCREATE POLICY "authenticated can receive broadcasts"@@ -920,13 +920,13 @@ USING ( true );```-See the [Realtime Authorization](/docs/guides/realtime/authorization) docs to learn how to set up more specific policies.+Read [Realtime Authorization](/docs/guides/realtime/authorization) to learn how to set up more specific policies.#### Set up trigger function-First, set up a trigger function that uses `realtime.broadcast_changes` to insert an event whenever it is triggered. The event is set up to include data on the schema, table, operation, and field changes that triggered it.+First, set up a trigger function that uses the `realtime.broadcast_changes()` function to insert an event whenever it is triggered. The event is set up to include data on the schema, table, operation, and field changes that triggered it.-For this example use case, we want to have a topic with the name `topic:<record id>` to which we're going to broadcast events.+For this example, you're going broadcast events to a topic named `topic:<record_id>`.```sqlCREATE OR REPLACE FUNCTION public.your_table_changes()@@ -948,7 +948,7 @@ END;$$ LANGUAGE plpgsql;```-Of note are the Postgres native trigger special variables used:+The Postgres native trigger special variables used are:- `TG_OP` - the operation that triggered the function- `TG_TABLE_NAME` - the table that caused the trigger@@ -1000,7 +1000,7 @@ Broadcast Replay enables **private** channels to access messages that were sentYou can configure replay with the following options:-- **`since`** (Required): The epoch timestamp in milliseconds (e.g., `1697472000000`), specifying the earliest point from which messages should be retrieved.+- **`since`** (Required): The epoch timestamp in milliseconds (for example, `1697472000000`), specifying the earliest point from which messages should be retrieved.- **`limit`** (Optional): The number of messages to return. This must be a positive integer, with a maximum value of 25.<Tabs