Skip to content

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

docs: add clarification about ssr with next.js prefetching

Stojan Dimitrovski66ae9a029025
diff --git a/apps/docs/pages/guides/auth/server-side-rendering.mdx b/apps/docs/pages/guides/auth/server-side-rendering.mdx
index 635407cd986..10ccfcf4e5b 100644
--- a/apps/docs/pages/guides/auth/server-side-rendering.mdx
+++ b/apps/docs/pages/guides/auth/server-side-rendering.mdx
@@ -160,6 +160,12 @@ use this potentially stale information to render a page.
## Frequently Asked Questions
+### No session on the server side with Next.js route prefetching?
+
+When you use route prefetching in Next.js using `<Link href="/...">` components or the `Router.push()` APIs can cause server-side requests to be sent out before the browser-side has had a chance to process the access and refresh tokens. This means that those requests may not have any cookies set, and your server code will render unauthenticated content.
+
+To go around this problem you can always redirect users back to one specific page after sign-in, where you will not be using any route prefetching magic from Next.js, and then once the Supabase client library running in the browser has had a chance to obtain the access and refresh tokens from the URL fragment, take the user to regular Next.js pages which can use prefetching.
+
### How do I make the cookies `HttpOnly`?
This is not necessary. Both the access token and refresh token are designed to