# Supabase SSR — card for AI agents

Supabase client library optimized for server-side rendering frameworks.

Category: SDKs for hosted services · npm package `@supabase/ssr` · latest version 0.12.7 (checked 2026-11-01)
Install: `npm install @supabase/ssr`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Supabase SSR
- Use `@supabase/ssr` only when server code needs the session. For browser-only session handling, use `createClient` from `@supabase/supabase-js` with your own `storage`.
- Do not add `@supabase/auth-helpers-nextjs`, `-react`, `-remix` or `-sveltekit`. The README lists them as deprecated; depend on `@supabase/ssr` directly.
- Do not pass `auth.storage` to `createBrowserClient` or `createServerClient`. It has no effect and logs a warning. `auth.userStorage` is respected only when `cookies.encode` is `"tokens-only"`.
- Follow the README's middleware example. Give `createServerClient` a `cookies.getAll` that parses the request's `Cookie` header with `parseCookieHeader`. Add a `cookies.setAll` that queues cookies and headers. Append each queued cookie with `serializeCookieHeader` as `Set-Cookie` and set the queued headers on the response.
- Refresh the session once per request in middleware with `await supabase.auth.getClaims()` before loaders and actions run.
- When parallel client requests may race to refresh the same expired token, handle `session: null` and retry or re-authenticate.
- For choosing between `getSession()`, `getUser()` and `getClaims()`, follow the official guides at https://supabase.com/docs/guides/auth/server-side.

## Docs written for agents
- [llms.txt (index of the docs)](https://supabase.com/llms.txt)

## What it is
- Supabase SSR (`@supabase/ssr`) is the package Supabase publishes for using its JavaScript client in server-side rendering frameworks. The repository describes it as "Supabase clients for use in server-side rendering frameworks". It is MIT licensed. The repository was created in May 2024.
- It exposes `createBrowserClient` and `createServerClient`. The README says both "always store the session in cookies", so the server and the browser share one session. In the README's React Router example, the server client receives `getAll` and `setAll` cookie functions. It reads the request's cookies and queues refreshed ones to write back onto the response.
- The README draws a clear line. If only the browser needs the session, it says there is no reason to use this package. The maintainers also present it as the replacement for the deprecated `@supabase/auth-helpers-*` packages for Next.js, React, Remix and SvelteKit.

## Caveats
- auth.storage is ignored: The README says passing `auth.storage` has no effect, and a one-time console warning is logged. The exception is `auth.userStorage`, which is still respected when `cookies.encode` is set to `"tokens-only"`.
- Wrong choice for browser-only apps: If the server never needs the session, the README points to `createClient` from `@supabase/supabase-js` with your own `storage`. It says there is "no reason" to use `@supabase/ssr` in that case.
- Racing refreshes can return a null session: Supabase refresh tokens are single-use. If two requests arrive at the same moment with the same expired cookie, such as two tabs opening together, the second refresh fails and that request gets `session: null`. The README says middleware mitigates this "for the common case". Parallel client `fetch()` calls still need to handle `null` sessions and retry or re-authenticate.

## Numbers (AgentGid data)
- Gid Score: 60.6 (#977 of all tools, 36 of 287 in its category)
- Used in 286 public projects set up for AI coding agents (4.6%)
- Downloads last week: 14,575,109 (as of 2026-11-24), +42.4% over 4 weeks
- GitHub stars: 217 (as of 2026-11-24)
- Last push: 2026-11-19

## Often used with
Supabase JS 97.9%, Next.js 93.7%, Lucide React 82.9%, Tailwind Merge 75.2%, clsx 75.5%, React 96.5%

## Links
- AgentGid page: https://agentgid.com/tools/supabase-ssr/
- Homepage: https://github.com/supabase/ssr#readme
- Repository: https://github.com/supabase/ssr
- Source: https://github.com/supabase/ssr#readme
- Source: https://github.com/supabase/ssr
- Source: https://github.com/supabase/ssr/releases

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
