Skip to content

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

realtime updates

Copplebdabadf91ed9
diff --git a/apps/www/_blog/2022-08-16-supabase-js-v2.mdx b/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
index 5d62d338199..bed3e9807f2 100644
--- a/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
+++ b/apps/www/_blog/2022-08-16-supabase-js-v2.mdx
@@ -98,7 +98,7 @@ A lot of developers didn't even realize they could use passwordless magic links.
The `insert()`, `update()`, and `upsert()` functions now require you to explicitly append `select()` if you want the data to be returned.
-```tsx
+```ts
// v2
const { data } = await supabase.from('messages').insert({ id: 1, message: 'Hello world' }).select() // select is now explicitly required
@@ -120,6 +120,40 @@ Previously you could pass a `returning: 'minimal'` option to the `insert()`, `up
</details>
+## Updated Realtime API
+
+There are a few changes to our Realtime interface:
+
+```ts
+// v2
+supabaseClient
+ .channel('any_string_you_want')
+ .on(
+ 'postgres_changes',
+ {
+ event: 'INSERT',
+ schema: 'public',
+ table: 'movies',
+ },
+ (payload) => {
+ console.log(payload)
+ }
+ )
+ .subscribe()
+
+// v1
+supabase
+ .from('movies')
+ .on('INSERT', (payload) => {
+ console.log(payload)
+ })
+ .subscribe()
+```
+
+There is a new `channel()` function which requires a string to denote the name of a channel.
+While this may seem more verbose, it's an important change for our upcoming [multiplayer](https://supabase.com/blog/supabase-realtime-with-multiplayer-features) features.
+You can listen to PostgreSQL database changes on any channel you want by subscribing to the `'postgres_changes'` event.
+
## Community
Version 2.0 is the result of the combined work of over 100 contributors to our libraries, and over 450 contributors to our docs and websites.