nextbase-auth-ssr
Skill827 starsChanged 3 months agoMITView on GitHub
Use for NextBase Supabase SSR authentication, browser/server/middleware clients, cookie propagation, protected routes, auth callbacks, redirects, getClaims, getUser, or session handling.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- nextbase-architectureSkill
- nextbase-cache-componentsSkill
- nextbase-database-testingSkill
- nextbase-safe-actions-dataSkill
- nextbase-testingSkill
- nextbase-ui-patternsSkill
- next-cache-components-optimizerSkill
- safe-action-advancedSkill
- safe-action-clientSkill
- safe-action-hooksSkill
- safe-action-middlewareSkill
- safe-action-testingSkill
- shadcnSkill
- supabase-postgres-best-practicesSkill
- supabase-schema-migrationsSkill
- supabaseSkill
- turborepoSkill
- vercel-composition-patternsSkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Only the publishable key may be used in browser-visible code.
- Very specific: line 21
Use getUser() when the request boundary must revalidate the user with Supabase, especially middleware/proxy route protection and sensitive …
- Very specific: line 22
Use getClaims() for locally verified claims and authenticated IDs inside already protected server work when its guarantees are sufficient.
- Very specific: line 23
Do not authorize from getSession() alone.
- Very specific: line 24
Use the request-memoized helpers in src/rsc-data/supabase.ts instead of repeating auth calls during one render.
- Very specific: line 28
Do not insert unrelated work between createServerClient() and the auth verification call in middleware.
- Distinctive: line 31
Do not treat the protected-route list as data authorization.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NextBase Auth SSR
Load the vendored supabase skill as well. Verify current Supabase SSR guidance before changing auth behavior.
Existing Client Boundaries
- Browser code uses
createClient()fromsrc/supabase-clients/client.ts. - Server Components, actions, and route handlers use
createSupabaseClient()fromsrc/supabase-clients/server.ts. src/supabase-clients/middleware.tsowns request/response cookie refresh. Preserve the completegetAll/setAllpropagation to both the request and response.src/proxy.tsowns route matching and delegates session refresh. Keep API and static-asset exclusions deliberate.
Only the publishable key may be used in browser-visible code. Never expose a secret or service_role key.
Verification Choice
- Use
getUser()when the request boundary must revalidate the user with Supabase, especially middleware/proxy route protection and sensitive re-verification. - Use
getClaims()for locally verified claims and authenticated IDs inside already protected server work when its guarantees are sufficient. - Do not authorize from
getSession()alone. A locally stored session is not a fresh authorization check. - Use the request-memoized helpers in
src/rsc-data/supabase.tsinstead of repeating auth calls during one render.
Middleware and Protected Routes
- Do not insert unrelated work between
createServerClient()and the auth verification call in middleware. - Match actual public URL segments, including nested routes. Test both the route root and a representative child route.
- Redirect anonymous users to
/loginwhile preserving cookies set on the Supabase response. - Do not treat the protected-route list as data authorization; RLS remains mandatory.
Callback Safety
- Exchange the code or verify the OTP before redirecting.
- Accept a
nextdestination only when it is a same-origin relative path beginning with one/and not//. Reject encoded or decoded absolute URLs and protocol-relative URLs. - Construct the final destination from an approved path and the request origin. Never pass arbitrary user input directly to
new URL(). - Send failed verification to
/auth/auth-code-errorand avoid logging tokens or cookie values. - Revalidate only after auth state changes successfully.
Verification
Cover anonymous redirect, authenticated access, cookie refresh, callback success, callback failure, and malicious next values. Use the real local Supabase stack for auth integration tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

