Skip to content

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

Update realtime broadcast docs (#34177)

Saxon Fletcher45f276c44470
diff --git a/apps/docs/content/guides/realtime/broadcast.mdx b/apps/docs/content/guides/realtime/broadcast.mdx
index 657e287d75c..579a9e726ed 100644
--- a/apps/docs/content/guides/realtime/broadcast.mdx
+++ b/apps/docs/content/guides/realtime/broadcast.mdx
@@ -693,12 +693,13 @@ The database broadcast feature provides two functions to help you send messages:
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.
```sql
-SELECT realtime.send (
- to_jsonb ('{}'::text), -- JSONB Payload
- 'event', -- Event name
- 'topic', -- Topic
- FALSE -- Public / Private flag
-);
+select
+ realtime.send(
+ jsonb_build_object('hello', 'world'), -- JSONB Payload
+ 'event', -- Event name
+ 'topic', -- Topic
+ false -- Public / Private flag
+ );
```
### Broadcast record changes
@@ -772,7 +773,9 @@ Finally, client side will requires to be set up to listen to the topic `topic:<r
const gameId = 'id'
await supabase.realtime.setAuth() // Needed for Realtime Authorization
const changes = supabase
- .channel(`topic:${gameId}`)
+ .channel(`topic:${gameId}`, {
+ config: { private: true },
+ })
.on('broadcast', { event: 'INSERT' }, (payload) => console.log(payload))
.on('broadcast', { event: 'UPDATE' }, (payload) => console.log(payload))
.on('broadcast', { event: 'DELETE' }, (payload) => console.log(payload))