docs: apply the docs style guide to the @supabase/server pages

Style pass only, per the `edit-the-docs` skill. No section moved, and no
behavior claim changed.

- The 1.x/2.x compatibility fact was stated three times on the frameworks
  page. It is stated once now, in the Versions admonition, which also stops
  restating the removal the body already covers.
- Long sentences split: the removal clause packed three versions and a date
  into one, and the `JWTClaims` index-signature paragraph ran 37 words.
- Negative and mannered constructions rewritten positively: "Do not rely on
  the compiler to catch" and "that is the case to worry about".
- "compiles clean" is an idiom that localizes badly, and `runtime` was the
  wrong term for the moment of execution. Now "compiles without error" and
  "at run time".
- The Edge Functions bridge setup was three actions in one prose sentence.
  It is a numbered procedure now, which is also what an agent can follow.
- Nuxt tutorial: the anonymous-mode paragraph carried a procedure, a process,
  a warning and navigation at once, with a silent-auth-bypass warning buried
  mid-paragraph. Split, with the warning in a caution admonition.
- Smaller fixes: Oxford comma, a reference page called a guide, a 42-word
  sentence hiding its performance claim in parentheses, the unintroduced
  `RLS` abbreviation, "See X for Y" link order, and an external GitHub Pages
  link left pointing away from the docs reference.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
yannbfandClaude Opus 5 committed 2026-11-25 17:49:26 +01:00
1 parent 584e6891a1
commit 68bee94687
8 files changed
+47 -27

No files matched your search

+14 -2
View File
@@ -130,7 +130,13 @@ app.get('/hello-world', (c) => {
export default { fetch: app.fetch }
```
To add [Supabase auth](/docs/guides/auth) per route, copy the [Hono bridge](/docs/reference/server/frameworks#hono) into your function and compose `withRequiredClaims()` from `npm:@supabase/server@^1/middleware/required-claims` with it. The bridge imports `hono` and `@supabase/middleware` by bare name, so map both in your function's `deno.json`. See [Securing Edge Functions](/docs/guides/functions/auth).
To add [Supabase auth](/docs/guides/auth) per route:
1. Copy the [Hono bridge](/docs/reference/server/frameworks#hono) into your function.
2. Add `hono` and `@supabase/middleware` to the `imports` field of your function's `deno.json`. The bridge imports both by bare name, so Deno resolves neither on its own.
3. Compose `withRequiredClaims()` from `npm:@supabase/server@^1/middleware/required-claims` into the bridge's entry array.
For per-request auth details, see [Securing Edge Functions](/docs/guides/functions/auth).
</TabPanel>
@@ -402,7 +408,13 @@ app.delete('/:id', async (c) => {
export default { fetch: app.fetch }
```
To add Supabase auth per route, copy the [Hono bridge](/docs/reference/server/frameworks#hono) into your function and compose `withRequiredClaims()` from `npm:@supabase/server@^1/middleware/required-claims` with it. The bridge imports `hono` and `@supabase/middleware` by bare name, so map both in your function's `deno.json`. See [Securing Edge Functions](/docs/guides/functions/auth).
To add Supabase auth per route:
1. Copy the [Hono bridge](/docs/reference/server/frameworks#hono) into your function.
2. Add `hono` and `@supabase/middleware` to the `imports` field of your function's `deno.json`. The bridge imports both by bare name, so Deno resolves neither on its own.
3. Compose `withRequiredClaims()` from `npm:@supabase/server@^1/middleware/required-claims` into the bridge's entry array.
For per-request auth details, see [Securing Edge Functions](/docs/guides/functions/auth).
</TabPanel>
@@ -365,9 +365,9 @@ At this stage you have a fully functional application!
So far the app authenticates the user on the client. For protected API endpoints or server-rendered data, you need a server route that verifies the session.
[`@supabase/server`](https://supabase.github.io/server/) handles the full flow: it validates the JWT locally (using your project's asymmetric signing keys, no round-trip to the Auth server), builds an RLS-scoped Supabase client and the caller's claims, and rejects unauthenticated requests with a 401 before any query runs.
[`@supabase/server`](/docs/reference/server) verifies the JWT against your project's asymmetric signing keys, builds a Supabase client scoped by Row Level Security, and rejects unauthenticated requests with a 401 before any query runs. Verification is local, so there is no round-trip to the Auth server.
Nuxt server routes get this through `createSupabaseContext`, which takes the request, verifies the credentials, and hands back a ready-to-use context. There is no file to copy and no Nuxt configuration to add: `h3`'s `toWebRequest` turns the event into the `Request` it expects.
Nuxt server routes get that context from `createSupabaseContext`, which takes the request, verifies the credentials, and returns the context. `h3`'s `toWebRequest` turns the event into the `Request` it expects.
```bash
npm install @supabase/server
@@ -414,4 +414,12 @@ export default defineEventHandler(async (event) => {
</$CodeTabs>
To let anonymous callers through, widen the mode to `auth: ['user', 'none']`. A valid token still produces a signed-in context; a request with no credentials falls through to `'none'` with `userClaims: null`, so the handler has to check for null before reading `userClaims.id`. A malformed or expired token is still rejected with a 401 rather than silently downgraded. Do not widen a route that is meant to be signed-in only: it turns a 401 into a 200. For app-wide auth, do the same check once in a Nuxt server middleware at `server/middleware/supabase.ts` and put the context on `event.context`. See the [server reference](/docs/reference/server) for the full API.
To let anonymous callers through, widen the mode to `auth: ['user', 'none']`. A valid token still produces a signed-in context. A request with no credentials falls through to `'none'` with `userClaims: null`, so the handler has to check for null before reading `userClaims.id`. A malformed or expired token is still rejected with a 401 rather than silently downgraded.
<Admonition type="caution">
Widening a signed-in-only route to `auth: ['user', 'none']` turns a 401 into a 200. Only widen a route that is meant to serve anonymous callers.
</Admonition>
For app-wide auth, do the same check once in a Nuxt server middleware at `server/middleware/supabase.ts` and put the context on `event.context`. For the full API, see the [server reference](/docs/reference/server).
+8 -8
View File
@@ -5,11 +5,11 @@ title: Frameworks
`@supabase/server` middleware runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project. The bridge runs a `@supabase/middleware` entry array in the framework's own middleware slot. Your route handlers then read `supabase`, `jwtClaims`, and any other key the entries contribute from the place your framework keeps per-request state.
The framework adapters (`@supabase/server/adapters/*`) predate the middleware engine. They were removed in `@supabase/server` 2.0.0, the removal announced for December 1, 2026 when they were deprecated in 1.9.0. The bridges on this page replace them. If you still import an adapter, read [Moving off the adapters](/docs/reference/server/frameworks#moving-off-the-adapters) before you change anything. One step in that migration can open an endpoint up without an error.
The framework adapters (`@supabase/server/adapters/*`) predate the middleware engine. They were deprecated in 1.9.0 and removed in `@supabase/server` 2.0.0. The bridges on this page replace them. If you still import an adapter, read [Moving off the adapters](/docs/reference/server/frameworks#moving-off-the-adapters) before you change anything. One step in that migration can open an endpoint up without an error.
<Admonition type="note" title="Versions">
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later, so they work on 1.x as well as 2.x. `withRequiredClaims` shipped in 1.5.1 and the entry form of `withSupabase` in 1.6.0. Releases before 1.5.1 have no `/middleware/*` exports. The adapters exist only on 1.x.
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later, and work the same on 1.x and 2.x. `withRequiredClaims` shipped in 1.5.1 and the entry form of `withSupabase` in 1.6.0. Releases before 1.5.1 have no `/middleware/*` exports.
The bridge file imports `@supabase/middleware`, so add it to your project as a direct dependency. `@supabase/server` depends on it, but a strict package manager such as pnpm does not let your code import a transitive dependency.
@@ -107,7 +107,7 @@ The bridge files live in the server repository under [`examples/frameworks`](htt
Copy [`h3/supabase-middleware.ts`](https://github.com/supabase/server/blob/main/examples/frameworks/h3/supabase-middleware.ts) into your project. `toH3` returns H3 middleware. H3 middleware return the response directly, so no workaround is needed.
This bridge is h3 v2: it uses `defineMiddleware`, `toResponse` and the `middleware` key on `defineHandler`, none of which exist in h3 v1. Nuxt 3 and Nuxt 4 both ship h3 v1, so the bridge does not build there. On Nuxt, call `createSupabaseContext` inside a plain `defineEventHandler` instead, as the [Nuxt tutorial](/docs/guides/getting-started/tutorials/with-nuxt-3) shows.
This bridge does not build on Nuxt. Nuxt 3 and Nuxt 4 both ship h3 v1, and the bridge is h3 v2: it uses `defineMiddleware`, `toResponse`, and the `middleware` key on `defineHandler`, none of which exist in h3 v1. On Nuxt, call `createSupabaseContext` inside a plain `defineEventHandler`, as the [Nuxt tutorial](/docs/guides/getting-started/tutorials/with-nuxt-3) shows.
`event.context` is not generic. Hoist the entry array to a `const` and read the keys through `Contributions<typeof entries>` from `@supabase/middleware`, or wrap that in a small typed accessor of your own.
@@ -272,7 +272,7 @@ The bridge files live in the server repository under [`examples/frameworks`](htt
Each adapter solved the same problem in a framework-specific way: build a `SupabaseContext` and stash it where the handler can reach it. That meant a published entry point, a peer dependency range, and a release cycle per framework, all to wrap one call. The engine replaced the model. A middleware is now an entry, a `(handler) => handler` wrapper over the Web `Request` and `Response` pair, and `withSupabaseClient()`, `withSupabaseAdminClient()`, `withRequiredClaims()`, and the rest are ordinary entries you compose. What remains is the bridge, and it belongs in your project, not in a package that has to track your framework's major versions.
The adapters were removed in 2.0.0. They still work on 1.x, so you can do this migration before you take the major or as part of taking it. `withSupabase(config, handler)` from `@supabase/server` is not part of this change.
The adapters were removed in 2.0.0. `withSupabase(config, handler)` from `@supabase/server` is unchanged.
Three changes come with the migration. The first can open an endpoint up.
@@ -376,7 +376,7 @@ For `supabase` and `supabaseAdmin` the rewrite is mechanical. For claims it is n
| `.appMetadata` | `.app_metadata` |
| `.userMetadata` | `.user_metadata` |
Do not rely on the compiler to catch a blanket rename of `userClaims` to `jwtClaims`. `JWTClaims` carries an index signature, so `jwtClaims.id` is legal and typed `unknown`: it errors where you assign it to a `string`, but `.eq('id', jwtClaims.id)` on a client with no `Database` generic compiles clean and writes `undefined` at runtime. `.id` is usually the value rows get written with, so that is the case to worry about. Rewrite each read against the table.
A blanket rename of `userClaims` to `jwtClaims` can compile and still be wrong. `JWTClaims` carries an index signature, so `jwtClaims.id` compiles and is typed `unknown`. Assigning it to a `string` is an error. Passing it to a client with no `Database` generic, as in `.eq('id', jwtClaims.id)`, compiles without error and writes `undefined` at run time. `.id` is usually the value rows get written with. Rewrite each read against the table.
### Step by step
@@ -387,7 +387,7 @@ Do the steps in order. The auth inventory comes before any code change, because
<RefSubLayout.EducationRow>
<RefSubLayout.Details>
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later. They work the same on 1.x and 2.x, so you can migrate first and take the major afterwards.
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later.
Then decide whether you need the response phase: an entry that sees the outgoing response and can rewrite it, which is what CORS and header-stamping middleware do. The table at the top of this page says what survives per framework. If you only read `supabase` inside a handler, you do not need it.
@@ -646,9 +646,9 @@ payload, with different field names:
userClaims.appMetadata -> jwtClaims.app_metadata
userClaims.userMetadata -> jwtClaims.user_metadata
Rewrite each read individually. Do NOT do a blanket rename. The compiler
will not reliably stop you: JWTClaims has an index signature, so jwtClaims.id
does not reliably stop you: JWTClaims has an index signature, so jwtClaims.id
is typed unknown rather than an error, and passing it to an untyped query
compiles clean and writes undefined.
compiles without error and writes undefined.
When finished there must be no remaining reference to `supabaseContext`.
STEP 6: VERIFY. Run the typecheck. Then, for every endpoint you listed in
+2 -2
View File
@@ -3,8 +3,8 @@ id: introduction
title: Introduction
---
`@supabase/server` is a framework-agnostic library for authenticating requests in server-side JavaScript environments. It verifies JWTs, resolves Supabase API keys, and creates pre-configured Supabase clients — exposing everything through a single `SupabaseContext` that is identical regardless of which layer produced it.
`@supabase/server` is a framework-agnostic library for authenticating requests in server-side JavaScript environments. It verifies JWTs, resolves Supabase API keys, and creates pre-configured Supabase clients. Everything is exposed through a single `SupabaseContext`, identical whether a bridge or a primitive produced it.
It runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project, described in the [Frameworks](/docs/reference/server/frameworks) guide. You can also compose the lower-level primitives directly for custom frameworks or edge runtimes.
It runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project. See [Frameworks](/docs/reference/server/frameworks). You can also compose the lower-level primitives directly for custom frameworks or edge runtimes.
Not sure this is the right package? See [which package to use](/docs/guides/auth/choosing-a-server-package) — for cookie-based sessions in SSR frameworks, use [`@supabase/ssr`](/docs/guides/auth/server-side) instead.
+1 -1
View File
@@ -3,7 +3,7 @@ id: usage-examples
title: Usage examples
---
Each example is a Fetch handler. Deno, Bun, and Supabase Edge Functions run the `export default { fetch }` shape as is. Cloudflare Workers also need the `nodejs_compat` flag or the `env` option, so `withSupabase` can read your project's URL and keys. On Node, use a framework bridge or the primitives with your framework.
Each example is a Fetch handler. Deno, Bun, and Supabase Edge Functions run the `export default { fetch }` shape as is. Cloudflare Workers also need the `nodejs_compat` flag or the `env` option, so `withSupabase` can read your project's URL and keys. On Node, use a framework bridge or compose the primitives yourself.
### Protect an endpoint with a user JWT
@@ -5,11 +5,11 @@ title: Frameworks
`@supabase/server` middleware runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project. The bridge runs a `@supabase/middleware` entry array in the framework's own middleware slot. Your route handlers then read `supabase`, `jwtClaims`, and any other key the entries contribute from the place your framework keeps per-request state.
The framework adapters (`@supabase/server/adapters/*`) predate the middleware engine. They were removed in `@supabase/server` 2.0.0, the removal announced for December 1, 2026 when they were deprecated in 1.9.0. The bridges on this page replace them. If you still import an adapter, read [Moving off the adapters](/docs/reference/server/frameworks#moving-off-the-adapters) before you change anything. One step in that migration can open an endpoint up without an error.
The framework adapters (`@supabase/server/adapters/*`) predate the middleware engine. They were deprecated in 1.9.0 and removed in `@supabase/server` 2.0.0. The bridges on this page replace them. If you still import an adapter, read [Moving off the adapters](/docs/reference/server/frameworks#moving-off-the-adapters) before you change anything. One step in that migration can open an endpoint up without an error.
<Admonition type="note" title="Versions">
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later, so they work on 1.x as well as 2.x. `withRequiredClaims` shipped in 1.5.1 and the entry form of `withSupabase` in 1.6.0. Releases before 1.5.1 have no `/middleware/*` exports. The adapters exist only on 1.x.
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later, and work the same on 1.x and 2.x. `withRequiredClaims` shipped in 1.5.1 and the entry form of `withSupabase` in 1.6.0. Releases before 1.5.1 have no `/middleware/*` exports.
The bridge file imports `@supabase/middleware`, so add it to your project as a direct dependency. `@supabase/server` depends on it, but a strict package manager such as pnpm does not let your code import a transitive dependency.
@@ -107,7 +107,7 @@ The bridge files live in the server repository under [`examples/frameworks`](htt
Copy [`h3/supabase-middleware.ts`](https://github.com/supabase/server/blob/main/examples/frameworks/h3/supabase-middleware.ts) into your project. `toH3` returns H3 middleware. H3 middleware return the response directly, so no workaround is needed.
This bridge is h3 v2: it uses `defineMiddleware`, `toResponse` and the `middleware` key on `defineHandler`, none of which exist in h3 v1. Nuxt 3 and Nuxt 4 both ship h3 v1, so the bridge does not build there. On Nuxt, call `createSupabaseContext` inside a plain `defineEventHandler` instead, as the [Nuxt tutorial](/docs/guides/getting-started/tutorials/with-nuxt-3) shows.
This bridge does not build on Nuxt. Nuxt 3 and Nuxt 4 both ship h3 v1, and the bridge is h3 v2: it uses `defineMiddleware`, `toResponse`, and the `middleware` key on `defineHandler`, none of which exist in h3 v1. On Nuxt, call `createSupabaseContext` inside a plain `defineEventHandler`, as the [Nuxt tutorial](/docs/guides/getting-started/tutorials/with-nuxt-3) shows.
`event.context` is not generic. Hoist the entry array to a `const` and read the keys through `Contributions<typeof entries>` from `@supabase/middleware`, or wrap that in a small typed accessor of your own.
@@ -272,7 +272,7 @@ The bridge files live in the server repository under [`examples/frameworks`](htt
Each adapter solved the same problem in a framework-specific way: build a `SupabaseContext` and stash it where the handler can reach it. That meant a published entry point, a peer dependency range, and a release cycle per framework, all to wrap one call. The engine replaced the model. A middleware is now an entry, a `(handler) => handler` wrapper over the Web `Request` and `Response` pair, and `withSupabaseClient()`, `withSupabaseAdminClient()`, `withRequiredClaims()`, and the rest are ordinary entries you compose. What remains is the bridge, and it belongs in your project, not in a package that has to track your framework's major versions.
The adapters were removed in 2.0.0. They still work on 1.x, so you can do this migration before you take the major or as part of taking it. `withSupabase(config, handler)` from `@supabase/server` is not part of this change.
The adapters were removed in 2.0.0. `withSupabase(config, handler)` from `@supabase/server` is unchanged.
Three changes come with the migration. The first can open an endpoint up.
@@ -376,7 +376,7 @@ For `supabase` and `supabaseAdmin` the rewrite is mechanical. For claims it is n
| `.appMetadata` | `.app_metadata` |
| `.userMetadata` | `.user_metadata` |
Do not rely on the compiler to catch a blanket rename of `userClaims` to `jwtClaims`. `JWTClaims` carries an index signature, so `jwtClaims.id` is legal and typed `unknown`: it errors where you assign it to a `string`, but `.eq('id', jwtClaims.id)` on a client with no `Database` generic compiles clean and writes `undefined` at runtime. `.id` is usually the value rows get written with, so that is the case to worry about. Rewrite each read against the table.
A blanket rename of `userClaims` to `jwtClaims` can compile and still be wrong. `JWTClaims` carries an index signature, so `jwtClaims.id` compiles and is typed `unknown`. Assigning it to a `string` is an error. Passing it to a client with no `Database` generic, as in `.eq('id', jwtClaims.id)`, compiles without error and writes `undefined` at run time. `.id` is usually the value rows get written with. Rewrite each read against the table.
### Step by step
@@ -387,7 +387,7 @@ Do the steps in order. The auth inventory comes before any code change, because
<RefSubLayout.EducationRow>
<RefSubLayout.Details>
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later. They work the same on 1.x and 2.x, so you can migrate first and take the major afterwards.
The bridges need `@supabase/server` 1.6.0 or later and Node 22 or later.
Then decide whether you need the response phase: an entry that sees the outgoing response and can rewrite it, which is what CORS and header-stamping middleware do. The table at the top of this page says what survives per framework. If you only read `supabase` inside a handler, you do not need it.
@@ -646,9 +646,9 @@ payload, with different field names:
userClaims.appMetadata -> jwtClaims.app_metadata
userClaims.userMetadata -> jwtClaims.user_metadata
Rewrite each read individually. Do NOT do a blanket rename. The compiler
will not reliably stop you: JWTClaims has an index signature, so jwtClaims.id
does not reliably stop you: JWTClaims has an index signature, so jwtClaims.id
is typed unknown rather than an error, and passing it to an untyped query
compiles clean and writes undefined.
compiles without error and writes undefined.
When finished there must be no remaining reference to `supabaseContext`.
STEP 6: VERIFY. Run the typecheck. Then, for every endpoint you listed in
@@ -3,9 +3,9 @@ id: introduction
title: Introduction
---
`@supabase/server` is a framework-agnostic library for authenticating requests in server-side JavaScript environments. It verifies JWTs, resolves Supabase API keys, and creates pre-configured Supabase clients — exposing everything through a single `SupabaseContext` that is identical regardless of which layer produced it.
`@supabase/server` is a framework-agnostic library for authenticating requests in server-side JavaScript environments. It verifies JWTs, resolves Supabase API keys, and creates pre-configured Supabase clients. Everything is exposed through a single `SupabaseContext`, identical whether a bridge or a primitive produced it.
It runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project, described in the [Frameworks](/docs/reference/server/frameworks) guide. You can also compose the lower-level primitives directly for custom frameworks or edge runtimes.
It runs inside Hono, H3, Elysia, NestJS, and TanStack Start through a bridge: one file you copy into your project. See [Frameworks](/docs/reference/server/frameworks). You can also compose the lower-level primitives directly for custom frameworks or edge runtimes.
<Admonition type="note" title="Not sure this is the right package?">
@@ -3,7 +3,7 @@ id: usage-examples
title: Usage examples
---
Each example is a Fetch handler. Deno, Bun, and Supabase Edge Functions run the `export default { fetch }` shape as is. Cloudflare Workers also need the `nodejs_compat` flag or the `env` option, so `withSupabase` can read your project's URL and keys. On Node, use a framework bridge or the primitives with your framework.
Each example is a Fetch handler. Deno, Bun, and Supabase Edge Functions run the `export default { fetch }` shape as is. Cloudflare Workers also need the `nodejs_compat` flag or the `env` option, so `withSupabase` can read your project's URL and keys. On Node, use a framework bridge or compose the primitives yourself.
### Protect an endpoint with a user JWT