Skip to content

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

docs: Add Dart code sample to the realtime authorization guide (#27976)

Tylera0b9b22a3d77
diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdx
index 791435a8166..8ec414cbf6f 100644
--- a/apps/docs/content/guides/realtime/authorization.mdx
+++ b/apps/docs/content/guides/realtime/authorization.mdx
@@ -123,27 +123,57 @@ exists (
Then, to join a topic with RLS enabled, instantiate the Channel with the `private` option set to `true`.
-```typescript
-import { createClient } from 'npm:@supabase/[email protected]'
-const url = 'https://<project_ref>.supabase.com'
-const apikey = '<api_key>'
-
-const client = createClient(url, apikey)
-
-const channel = client.channel('room-1', {
- config: { private: true },
-})
-
-channel
- .on('broadcast', { event: 'test' }, (payload) => console.log(payload))
- .subscribe((status: string, err: any) => {
- if (status === 'SUBSCRIBED') {
- console.log('Connected!')
- } else {
- console.error(err)
- }
- })
-```
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="js"
+ queryGroup="language"
+>
+ <TabPanel id="js" label="JavaScript">
+ ```typescript
+ import { createClient } from 'npm:@supabase/[email protected]'
+ const url = 'https://<project_ref>.supabase.com'
+ const apikey = '<api_key>'
+
+ const client = createClient(url, apikey)
+
+ const channel = client.channel('room-1', {
+ config: { private: true },
+ })
+
+ channel
+ .on('broadcast', { event: 'test' }, (payload) => console.log(payload))
+ .subscribe((status: string, err: any) => {
+ if (status === 'SUBSCRIBED') {
+ console.log('Connected!')
+ } else {
+ console.error(err)
+ }
+ })
+ ```
+
+ </TabPanel>
+ <TabPanel id="dart" label="Dart">
+ ```dart
+ final channel = supabase.channel(
+ 'room-1',
+ opts: const RealtimeChannelConfig(private: true),
+ );
+
+ channel
+ .onBroadcast(event: 'test', callback: (payload) => print(payload))
+ .subscribe((status, err) {
+ if (status == RealtimeSubscribeStatus.subscribed) {
+ print('Connected!');
+ } else {
+ print(err);
+ }
+ });
+ ```
+
+ </TabPanel>
+</Tabs>
#### Allow a user to send a Broadcast message