The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Merge pull request #11549 from supabase/docs/nextjs-server-components
dng39b6dd49066d
diff --cc apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdxindex efbfb1a4326,b461b029637..4f60e7d3581--- a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx+++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx@@@ -207,20 -230,21 +230,21 @@@ export const createClient = () => creat><TabPanel id="js" label="JavaScript">- Create a `/components/supabase-listener.jsx` file and add the following:+ Next, we need to create a single instance of Supabase to use client-side. Let's create a new Provider for Supabase at `/components/supabase-provider.jsx` and populate with the following:- ```jsx title="/components/supabase-listener.jsx"+ ```jsx title=components/supabase-provider.jsx'use client'- import { useRouter } from 'next/navigation'- import { useEffect } from 'react'- import supabase from '../utils/supabase-browser'+ import { createContext, useContext, useState } from 'react'+ import { createClient } from '../utils/supabase-browser'- export default function SupabaseListener({ accessToken }) {- const router = useRouter()+ const Context = createContext()++ export default function SupabaseProvider({ children }) {+ const [supabase] = useState(() => createClient())useEffect(() => {- const { data: subscription } = supabase.auth.onAuthStateChange((event, session) => {+ const { data: { subscription } } = supabase.auth.onAuthStateChange((event, session) => {if (session?.access_token !== accessToken) {router.refresh()}