Skip to content

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

fix: update realtime code to v2 on realtime overview page (#18264)

Tyler09adec629000
diff --git a/apps/docs/pages/guides/realtime.mdx b/apps/docs/pages/guides/realtime.mdx
index a043d596c5c..590a6c0412c 100644
--- a/apps/docs/pages/guides/realtime.mdx
+++ b/apps/docs/pages/guides/realtime.mdx
@@ -64,7 +64,10 @@ const handleInserts = (payload) => {
}
// Listen to inserts
-const { data: todos, error } = await supabase.from('todos').on('INSERT', handleInserts).subscribe()
+supabase
+ .channel('todos')
+ .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'todos' }, handleInserts)
+ .subscribe()
```
Use [subscribe()](/docs/reference/javascript/subscribe) to listen to database changes.