mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem The "How it works" section of the SSR advanced guide says the tokens must be stored in cookies, but not that `@supabase/ssr` does this. A reader who signs a user in on one server route can't tell how a later request gets the session back, so they may pass tokens around and call `setSession` themselves. Related to [FDBKIN-20417](https://linear.app/supabase/issue/FDBKIN-20417/clarify-server-side-session-management-across-multiple-http-requests) Closes [DOCS-1765](https://linear.app/supabase/issue/DOCS-1765/explain-how-a-server-side-session-carries-over-to-the-next-request) ## Solution Two paragraphs in "How it works" on the SSR advanced guide explain the cookie round trip. On sign-in, a code exchange, a refresh, or a user update, the server client writes the session through `setAll`. On the next request, a new server client reads it back through `getAll`, with no `setSession` call. The framework setup stays on "Creating a Supabase client for SSR", which the new text links to. ## How to verify 1. Open `/docs/guides/auth/server-side/advanced-guide` on the preview and go to "How it works". 2. Check that the section says a server-side sign-in with `createServerClient` writes the session, access and refresh tokens included, to the `sb-<project_ref>-auth-token` cookie through `setAll`. 3. Check that it says a new server client on a later request restores the session through `getAll`, with no `setSession` call. 4. Click the "Creating a Supabase client for SSR" link and check that it opens that page. ## Checks Ran `pnpm turbo run typecheck --filter='...[origin/master]'`, `pnpm turbo run lint --filter='[origin/master]'`, and `pnpm exec oxfmt --check` on the changed file. Checked the facts against `@supabase/ssr` 0.12.7 (`createServerClient.js`, `cookies.js`, `utils/chunker.js`) and the cookie name on "Creating a Supabase client for SSR". Skipped the docs tests: they need Docker. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) ## Feedback for Tedd To ask Tedd for a change to this PR, reply in Tedd's session on [DOCS-1765](https://linear.app/supabase/issue/DOCS-1765/explain-how-a-server-side-session-carries-over-to-the-next-request). Tedd doesn't read comments on this PR. --------- Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>