Auth
Your Supabase API route lets logged-out users in after you move off the adapter
Cataloged November 14, 2026 · Supabase
Symptom
A request with no credentials can return 200 after withClaims() replaces an adapter that used auth: 'user'. The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says: "Do not use withClaims() in place of auth: 'user'. The adapter rejected anonymous requests. withClaims() lets them through with jwtClaims: null, which turns a 401 into a 200 with no error." The Supabase docs page "Server: Frameworks" says withClaims() rejects a token that is present and invalid, but a request with no credentials is not an error to it. It contributes jwtClaims: null and falls through by design. Nothing throws and nothing logs. The endpoint returns 200 with whatever Row Level Security lets the anonymous role see, often an empty array, which reads like a data bug. The Supabase docs page "Server: withClaims" says "withClaims is not an auth gate. It never rejects a request that has no token." This applies to apps whose server code uses @supabase/server, often generated by AI coding tools for Supabase Edge Functions or a Hono, H3, Elysia, or NestJS backend. If you don't use @supabase/server, this card doesn't apply.
Root cause
The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says the adapter rejected anonymous requests, and that withClaims() lets them through with jwtClaims: null, which turns a 401 into a 200 with no error. The same entry says: "Do not use withClaims() in place of auth: 'user'." The Supabase docs page "Server: withClaims" says "withClaims is not an auth gate. It never rejects a request that has no token." The Supabase docs page "Server: Frameworks" says withClaims() rejects a token that is present and invalid, but a request with no credentials is not an error to it. It contributes jwtClaims: null and falls through by design. Nothing throws and nothing logs. The endpoint returns 200 with whatever Row Level Security lets the anonymous role see, often an empty array, which reads like a data bug. That changelog says the four adapters @supabase/server/adapters/hono, /h3, /elysia and /nestjs still work today and will be removed from the package on December 1, 2026, and that withSupabase(config, handler), its entry form withSupabase(config), and the @supabase/server/middleware/* entries are not deprecated. The same entry says the replacement is a bridge: one file you copy into your project that runs a @supabase/middleware entry array inside your framework's own middleware slot, with bridges for Hono, H3, Elysia, NestJS and TanStack Start. The same entry says those bridges need @supabase/server 1.6.0 or later and Node 22 or later, and that you add @supabase/middleware as a direct dependency. That changelog says to grep for @supabase/server/adapters and note the auth value each withSupabase(...) call uses. A bare withSupabase() counts as auth: 'user'. auth: 'user' becomes withRequiredClaims(). auth: 'none' needs no gate. auth: 'publishable' and auth: 'secret' have no bridge entry, so those endpoints stay on withSupabase. The Supabase docs page "Server: withRequiredClaims" says that with no Authorization: Bearer token the response is 401 MISSING_CREDENTIALS and the handler never runs. An sb_* API key in that position is 401 UNUSABLE_CREDENTIAL. An invalid token is 401 INVALID_JWT. The Supabase docs page "Server: Frameworks" says the correct Hono form is new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...). That page says to import withRequiredClaims from '@supabase/server/middleware/required-claims', withSupabaseClient from '@supabase/server/middleware/client', and toHono from the copied bridge file. It shows the form before the move as app.use('*', withSupabase({ auth: 'user' })), and the wrong form after the move as toHono([withClaims(), withSupabaseClient()]). That page says to register the toHono middleware before the routes it gates. Hono applies middleware only to routes added after it, so a route added first runs with no gate and no error. It also says app.use(...) on one line and app.get(...) on the next typecheck the middleware but leave c.var untyped. The gate still runs, so a failing typecheck is the only signal. That page says to chain .use() into the routes. The changelog says the adapters exposed one nested supabaseContext object, and entries contribute flat keys c.var.supabase and c.var.jwtClaims. No entry contributes userClaims. userClaims.id becomes jwtClaims.sub. The Supabase docs page "Server: withRequiredClaims" says the 401 short-circuits carry no CORS headers and a bare pipeline answers no OPTIONS preflight. For browser callers, that page says to compose withCors from @supabase/middleware/cors ahead of the gate. That page says withClaims and withRequiredClaims share the jwtClaims key, so composing both is a compile-time conflict. The changelog says to verify by running the typecheck, then confirming every endpoint that rejected anonymous requests before still returns 401 without a token. It also says the frameworks guide includes a prompt you can hand to a coding agent to do the migration.
Before and after
The before line is the wrong migration named on the Supabase docs page "Server: Frameworks": toHono([withClaims(), withSupabaseClient()]). The form that page shows before the move is app.use('*', withSupabase({ auth: 'user' })). The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says: "Do not use withClaims() in place of auth: 'user'. The adapter rejected anonymous requests. withClaims() lets them through with jwtClaims: null, which turns a 401 into a 200 with no error." The after line is the correct Hono form on the Frameworks page, chained into the route: new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...). That page says to chain .use() into the routes. Hono applies middleware only to routes added after it, so a route added first runs with no gate and no error. It says app.use(...) on one line and app.get(...) on the next typecheck the middleware but leave c.var untyped. The gate still runs, so a failing typecheck is the only signal.
Before
toHono([withClaims(), withSupabaseClient()])
After
new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...)Fix prompt
In this project only. Do not scan or test anyone else's app. Do not print keys, tokens, passwords, JWTs, Authorization header values, or environment variable values. When you mention a variable, print the name only. Do not send a request to any URL.
1. This prompt applies if this project's server code uses @supabase/server. That package is often generated by AI coding tools for Supabase Edge Functions or a Hono, H3, Elysia, or NestJS backend. If this project does not import @supabase/server, say so and stop. This card doesn't apply.
2. Search this project's own files for @supabase/server/adapters and for withClaims(. For each withSupabase(...) call, give the file, the line, and the auth value. The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says to grep for @supabase/server/adapters and note the auth value each withSupabase(...) call uses. A bare withSupabase() counts as auth: 'user'. Do not print keys or env values.
3. Where the auth value is 'user', or the call is a bare withSupabase(), replace that gate with withRequiredClaims(). That changelog says auth: 'user' becomes withRequiredClaims(). Do not write withClaims() in that place. The changelog says: "Do not use withClaims() in place of auth: 'user'. The adapter rejected anonymous requests. withClaims() lets them through with jwtClaims: null, which turns a 401 into a 200 with no error." The Supabase docs page "Server: withClaims" says "withClaims is not an auth gate. It never rejects a request that has no token." Do not change Row Level Security policies, and do not edit the query to fill an empty array. The Supabase docs page "Server: Frameworks" says the endpoint returns 200 with whatever Row Level Security lets the anonymous role see, often an empty array, which reads like a data bug. Show me the diff.
4. Where the auth value is 'none', do not add a gate. That changelog says auth: 'none' needs no gate. Where the auth value is 'publishable' or 'secret', leave the endpoint on withSupabase. That changelog says auth: 'publishable' and auth: 'secret' have no bridge entry, so those endpoints stay on withSupabase. Show me the diff for the 'user' calls only.
5. The replacement is a bridge: one file copied into this project that runs a @supabase/middleware entry array inside this framework's own middleware slot. That changelog says bridges exist for Hono, H3, Elysia, NestJS and TanStack Start. They need @supabase/server 1.6.0 or later and Node 22 or later. Add @supabase/middleware as a direct dependency. Do not upgrade unrelated packages. withSupabase(config, handler), its entry form withSupabase(config), and the @supabase/server/middleware/* entries are not deprecated. Do not delete those. If this project is not on @supabase/server 1.6.0 or later, or not on Node 22 or later, say so and do not copy a bridge. If the bridge file is not already in this project, stop. Tell me to copy the one file that changelog describes, the file that runs a @supabase/middleware entry array inside this framework's middleware slot. Do not write a bridge from scratch. Do not print secret values.
6. If this project uses Hono, use the form on the Supabase docs page "Server: Frameworks": new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...). Import withRequiredClaims from '@supabase/server/middleware/required-claims'. Import withSupabaseClient from '@supabase/server/middleware/client'. Import toHono from the bridge file copied into this project. Do not write toHono([withClaims(), withSupabaseClient()]). Register toHono before the routes it gates, and chain .use() into the routes. That page says Hono applies middleware only to routes added after it, so a route added first runs with no gate and no error. It says app.use(...) on one line and app.get(...) on the next typecheck the middleware but leave c.var untyped. The gate still runs, so a failing typecheck is the only signal. If this project is H3, Elysia, NestJS, or TanStack Start, do not paste the Hono form. That changelog says bridges exist for those frameworks. Use the bridge for this project's framework, with withRequiredClaims() where the adapter used auth: 'user'. Show me the diff.
7. Update reads of the old context in this project. That changelog says the adapters exposed one nested supabaseContext object, and entries contribute flat keys c.var.supabase and c.var.jwtClaims. No entry contributes userClaims. userClaims.id becomes jwtClaims.sub. Do not compose withClaims() and withRequiredClaims() in the same array. The Supabase docs page "Server: withRequiredClaims" says they share the jwtClaims key, so composing both is a compile-time conflict. Show me the diff.
8. If browser code in this project calls the endpoint, compose withCors from @supabase/middleware/cors ahead of the gate. The Supabase docs page "Server: withRequiredClaims" says the 401 short-circuits carry no CORS headers and a bare pipeline answers no OPTIONS preflight. If no browser code in this project calls the endpoint, do not add withCors. Say which you found. Show me the diff.
9. Run this project's typecheck and show me the result. That changelog says to run the typecheck, then confirm every endpoint that rejected anonymous requests before still returns 401 without a token. Do not send the request. Tell me to call one protected endpoint in this project with no Authorization header, for example curl -i against my own function URL, and confirm a 401, not a 200. The Supabase docs page "Server: withRequiredClaims" says that with no Authorization: Bearer token the response is 401 MISSING_CREDENTIALS and the handler never runs. An sb_* API key in that position is 401 UNUSABLE_CREDENTIAL. An invalid token is 401 INVALID_JWT. The changelog says the frameworks guide includes a prompt you can hand to a coding agent to do the migration. If you use that prompt, use it on this project only. The gate where the adapter used auth: 'user' is withRequiredClaims().
Do not print keys. Do not edit unrelated files.Paste this into the coding tool that has your own project open.
2-minute self-check
These steps are for an app you own. Do not run them against someone else's project.
- In your own project, search for @supabase/server/adapters. The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says to grep for that path and note the auth value each withSupabase(...) call uses. A bare withSupabase() counts as auth: 'user'. If this project does not use @supabase/server, this card doesn't apply. Do not search a repository you do not own.
- In your own project, search for withClaims(. That changelog says: "Do not use withClaims() in place of auth: 'user'. The adapter rejected anonymous requests. withClaims() lets them through with jwtClaims: null, which turns a 401 into a 200 with no error." The Supabase docs page "Server: withClaims" says "withClaims is not an auth gate. It never rejects a request that has no token." Do not search a repository you do not own.
- Call one protected endpoint in an app you own, with no Authorization header. For example, run curl -i against your own function URL. Confirm a 401, not a 200. That changelog says to confirm every endpoint that rejected anonymous requests before still returns 401 without a token. The Supabase docs page "Server: withRequiredClaims" says that with no Authorization: Bearer token the response is 401 MISSING_CREDENTIALS and the handler never runs. If the response is 200 and the body is an empty array, the Supabase docs page "Server: Frameworks" says withClaims() contributes jwtClaims: null and falls through by design. Nothing throws and nothing logs. The endpoint returns 200 with whatever Row Level Security lets the anonymous role see, often an empty array, which reads like a data bug. Do not call an endpoint you do not own, and do not send a token.
- In your own Hono file, confirm the gate is chained as new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...). The Supabase docs page "Server: Frameworks" says to register toHono before the routes it gates, and to chain .use() into the routes. Hono applies middleware only to routes added after it, so a route added first runs with no gate and no error. That page says app.use(...) on one line and app.get(...) on the next typecheck the middleware but leave c.var untyped. The gate still runs, so a failing typecheck is the only signal. Do not inspect an app you do not own.
Common questions
The list comes back empty and nothing is logged. Is the query wrong?
The Supabase docs page "Server: Frameworks" says withClaims() rejects a token that is present and invalid, but a request with no credentials is not an error to it. It contributes jwtClaims: null and falls through by design. Nothing throws and nothing logs. The endpoint returns 200 with whatever Row Level Security lets the anonymous role see, often an empty array, which reads like a data bug. The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says withClaims() lets anonymous requests through with jwtClaims: null, which turns a 401 into a 200 with no error. The Supabase docs page "Server: withClaims" says "withClaims is not an auth gate. It never rejects a request that has no token."
The adapter import still works. Can I leave auth: 'user' on withSupabase?
The Supabase changelog entry "Framework adapters in @supabase/server are deprecated" (Oct 5, 2026) says the four adapters @supabase/server/adapters/hono, /h3, /elysia and /nestjs still work today and will be removed from the package on December 1, 2026. withSupabase(config, handler), its entry form withSupabase(config), and the @supabase/server/middleware/* entries are not deprecated. auth: 'user' becomes withRequiredClaims(). auth: 'none' needs no gate. auth: 'publishable' and auth: 'secret' have no bridge entry, so those endpoints stay on withSupabase. When you move an auth: 'user' call, that changelog says: "Do not use withClaims() in place of auth: 'user'."
Typecheck complains about c.var, but the route still answers. Did the gate run?
The Supabase docs page "Server: Frameworks" says app.use(...) on one line and app.get(...) on the next typecheck the middleware but leave c.var untyped. The gate still runs, so a failing typecheck is the only signal. That page says to chain .use() into the routes. The correct Hono form on that page is new Hono().use('*', toHono([withRequiredClaims(), withSupabaseClient()])).get(...). That page also says Hono applies middleware only to routes added after it, so a route added first runs with no gate and no error. The Supabase docs page "Server: withRequiredClaims" says that with no Authorization: Bearer token the response is 401 MISSING_CREDENTIALS and the handler never runs. That page says withClaims and withRequiredClaims share the jwtClaims key, so composing both is a compile-time conflict.