The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
updates to the realtime docs
Copple208279d2cd73
diff --git a/apps/docs/components/Navigation/Navigation.constants.ts b/apps/docs/components/Navigation/Navigation.constants.tsindex 94f40fce1ee..beb5bdc962d 100644--- a/apps/docs/components/Navigation/Navigation.constants.ts+++ b/apps/docs/components/Navigation/Navigation.constants.ts@@ -241,12 +241,57 @@ export const menuItems: NavMenu = {{label: 'Realtime',items: [- { name: 'Overview', url: '/guides/realtime', items: [] },- { name: 'Quickstart', url: '/guides/realtime/quickstart', items: [] },- { name: 'Broadcast', url: '/guides/realtime/broadcast', items: [] },- { name: 'Presence', url: '/guides/realtime/presence', items: [] },- { name: 'Postgres Changes', url: '/guides/realtime/postgres-changes', items: [] },- { name: 'Rate Limits', url: '/guides/realtime/rate-limits', items: [] },+ {+ name: 'Overview',+ url: '/guides/realtime',+ items: [],+ },+ {+ name: 'Quickstart',+ url: '/guides/realtime/quickstart',+ items: [],+ },+ {+ name: 'Features',+ url: undefined,+ items: [+ { name: 'Channels', url: '/guides/realtime/channels', items: [] },+ {+ name: 'Extensions',+ url: '/guides/realtime/extensions',+ items: [+ { name: 'Broadcast', url: '/guides/realtime/broadcast', items: [] },+ { name: 'Presence', url: '/guides/realtime/presence', items: [] },+ { name: 'Postgres Changes', url: '/guides/realtime/postgres-changes', items: [] },+ ],+ },+ ],+ },+ {+ name: 'Guides',+ url: undefined,+ items: [+ {+ name: 'Subscribing to Database Changes',+ url: '/guides/realtime/subscribing-to-database-changes',+ items: [],+ },+ {+ name: 'Using Realtime with Next.js',+ url: '/guides/realtime/realtime-with-nextjs',+ items: [],+ },+ ],+ },+ {+ name: 'Deep dive',+ url: undefined,+ items: [+ { name: 'Rate Limits', url: '/guides/realtime/rate-limits', items: [] },+ { name: 'Architecture', url: '/guides/realtime/architecture', items: [] },+ { name: 'Protocol', url: '/guides/realtime/protocol', items: [] },+ ],+ },],},{diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 6ba1f18099a..cf5b2f0a4ca 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -522,26 +522,40 @@ export const realtime = {url: undefined,items: [{ name: 'Channels', url: '/guides/realtime/channels', items: [] },- { name: 'Extensions', url: '/guides/realtime/extensions', items: [] },+ {+ name: 'Extensions',+ url: '/guides/realtime/extensions',+ items: [+ { name: 'Broadcast', url: '/guides/realtime/broadcast', items: [] },+ { name: 'Presence', url: '/guides/realtime/presence', items: [] },+ { name: 'Postgres Changes', url: '/guides/realtime/postgres-changes', items: [] },+ ],+ },],},{name: 'Guides',url: undefined,items: [- { name: 'Broadcast', url: '/guides/realtime/broadcast', items: [] },- { name: 'Presence', url: '/guides/realtime/presence', items: [] },- { name: 'Postgres Changes', url: '/guides/realtime/postgres-changes', items: [] },+ {+ name: 'Subscribing to Database Changes',+ url: '/guides/realtime/subscribing-to-database-changes',+ items: [],+ },+ {+ name: 'Using Realtime with Next.js',+ url: '/guides/realtime/realtime-with-nextjs',+ items: [],+ },],},{- name: 'Discover',+ name: 'Deep dive',url: undefined,items: [{ name: 'Rate Limits', url: '/guides/realtime/rate-limits', items: [] },{ name: 'Architecture', url: '/guides/realtime/architecture', items: [] },{ name: 'Protocol', url: '/guides/realtime/protocol', items: [] },- { name: 'Videos', url: '/guides/realtime/videos', items: [] },],},],diff --git a/apps/docs/pages/guides/realtime/extensions.mdx b/apps/docs/pages/guides/realtime/extensions.mdxindex 07dd98904fb..bad8b1daf66 100644--- a/apps/docs/pages/guides/realtime/extensions.mdx+++ b/apps/docs/pages/guides/realtime/extensions.mdx@@ -8,11 +8,19 @@ export const meta = {sidebar_label: 'Extensions',}-Extensions are pluggable feature sets enabled by initializing a Realtime connection with certain message types.+Supabase Realtime provides multiplayer features so that you can build real-time applications. The server is has several extensions which are built to solve a specific task.-[Broadcast](/docs/guides/realtime/broadcast), [Presence](/docs/guides/realtime/presence) and [Postgres Changes](/docs/guides/realtime/postgres-changes) are all Realtime Extensions. Some Extensions, like Postgres Changes, require backend configuration to be saved on the cluster before use.+- [Broadcast](/docs/guides/realtime/broadcast): for sending rapid, ephemeral messages to other connected clients. A typical use-case is tracking mouse movements.+- [Presence](/docs/guides/realtime/presence): for sending user state between connected clients. A typical use-case is simply an "online" status, which will disappear when a user is disconnected.+- [Postgres Changes](/docs/guides/realtime/postgres-changes): for receiving database changes in real-time.-For example, Realtime needs your database credentials to know how to connect to your database and you don't want to send those over a client connection.+## Choosing between Broadcast and Presence++Defaulting to using Broadcast is a good idea, and then use Presence sparingly. The Presence extension merges all changes into a shared state for every client connected to the same "channel". If you _do_ use Presence, it's best to throttle your changes so that you are sending updates less frequently.++## Future possibilities++Realtime extensions are still under development. We have many more extensions planned. You can follow our progress by watching the [Realtime](https://github.com/supabase/realtime) repo on GitHub.export const Page = ({ children }) => <Layout meta={meta} children={children} />diff --git a/apps/docs/pages/guides/realtime/videos.mdx b/apps/docs/pages/guides/realtime/realtime-with-nextjs.mdxsimilarity index 58%rename from apps/docs/pages/guides/realtime/videos.mdxrename to apps/docs/pages/guides/realtime/realtime-with-nextjs.mdxindex a2a67f23a9b..e60afb4f74a 100644--- a/apps/docs/pages/guides/realtime/videos.mdx+++ b/apps/docs/pages/guides/realtime/realtime-with-nextjs.mdx@@ -1,13 +1,14 @@import Layout from '~/layouts/DefaultGuideLayout'export const meta = {- id: 'videos',- title: 'Videos',- description: 'Video guides for Supabase Realtime',+ id: 'realtime-with-nextjs',+ title: 'Using Realtime with Next.js',+ description: 'Client & Server Components in Next.js with Realtime Updates',sidebar_label: 'Videos',}-## Client & Server Components in Next.js with Realtime Updates+In this guide we explore the best ways to receive realtime Postgres changes with your Next.js application.+We'll show both client and serverside updates, and explore the which option is best.<div className="video-container"><iframediff --git a/apps/docs/pages/guides/realtime/subscribing-to-database-changes.mdx b/apps/docs/pages/guides/realtime/subscribing-to-database-changes.mdxnew file mode 100644index 00000000000..f22764ac7c8--- /dev/null+++ b/apps/docs/pages/guides/realtime/subscribing-to-database-changes.mdx@@ -0,0 +1,80 @@+import Layout from '~/layouts/DefaultGuideLayout'++export const meta = {+ id: 'subscribing-to-database-changes',+ title: 'Subscribing to Database Changes',+ description: 'Listen to database changes in real-time from your website or application.',+ sidebar_label: 'Videos',+}++Supabase allows you to subscribe to real-time changes on your database from your client application.++You can listen to database changes using the [Postgres Changes](/docs/guides/realtime/postgres-changes) extension.++## Demo++<div className="video-container">+ <iframe+ src="https://www.youtube-nocookie.com/embed/2rUjcmgZDwQ"+ frameBorder="1"+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"+ allowFullScreen+ ></iframe>+</div>++## Streaming inserts++You can use the `INSERT` event to stream all new rows.++```js+const { createClient } = require('@supabase/supabase-js')++const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)++const channel = supabase+ .channel('schema-db-changes')+ .on(+ 'postgres_changes',+ {+ event: 'INSERT',+ schema: 'public',+ },+ (payload) => console.log(payload)+ )+ .subscribe()+```++## Streaming updates++You can use the `UPDATE` event to stream all updated rows.++```js+const { createClient } = require('@supabase/supabase-js')++const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY)++const channel = supabase+ .channel('schema-db-changes')+ .on(+ 'postgres_changes',+ {+ event: 'UPDATE',+ schema: 'public',+ },+ (payload) => console.log(payload)+ )+ .subscribe()+```++## More resources++- Learn more about the [Postgres Changes](/docs/guides/realtime/postgres-changes) extension.+- Client Libraries:+ - [JavaScript](/docs/reference/javascript/subscribe)+ - [Flutter](/docs/reference/dart/stream)+ - [Python](/docs/reference/python/subscribe)+ - [C#](/docs/reference/csharp/subscribe)++export const Page = ({ children }) => <Layout meta={meta} children={children} />++export default Page