Skip to content

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

Update nextjs-server-components.mdx

Gustavo Santosdad09f937d4c
diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx
index 35861d98c86..9c1efcd155c 100644
--- a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx
+++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx
@@ -220,11 +220,13 @@ export default function SupabaseListener({ accessToken }) {
const router = useRouter()
useEffect(() => {
- supabase.auth.onAuthStateChange((event, session) => {
+ const event = supabase.auth.onAuthStateChange((event, session) => {
if (session?.access_token !== accessToken) {
router.refresh()
}
})
+
+ return () => event.data.subscription.unsubscribe();
}, [accessToken])
return null