Skip to content
Back to skills

Nextjs Supabase Auth

ASecurity

Integrate Supabase Auth with Next.js App Router using middleware, callback handling, protected routes, and server/client client boundaries.

  • 383 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added June 6, 2026
testinggonextjsdebugging

Works with

  • cli

Security analysis

A100/100

Scanned June 6, 2026

npx -y skills add Asymmetric-al/core --skill nextjs-supabase-auth --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs Supabase Auth?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nextjs Supabase Auth
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/asymmetric-al-nextjs-supabase-auth/badge)](https://www.skillsdirectory.com/skills/asymmetric-al-nextjs-supabase-auth)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nextjs-supabase-auth
description: Integrate Supabase Auth with Next.js App Router using middleware, callback handling, protected routes, and server/client client boundaries.
metadata:
  owner: "skills-steward"
  last_updated: 2026-02-18
  status: "active"
  upstream:
    repo: "supabase/agent-skills"
    related_guides:
      - "https://supabase.com/docs/guides/auth/server-side/nextjs"
      - "https://supabase.com/docs/guides/auth"
license: MIT
---

# Next.js + Supabase Auth

Use this skill for authentication work in Next.js App Router with Supabase Auth.

## When to Apply

Use this skill when:

- Implementing login/signup/logout and session flows
- Protecting routes with middleware
- Handling auth callback exchanges
- Wiring auth checks in Server Components, Server Actions, and route handlers
- Debugging cookie/session desync between server and client

Do not use this skill when:

- The task is primarily query/index/schema optimization (use `supabase-postgres-best-practices`)
- The task spans broader Supabase surface area beyond Next.js auth wiring (use `docs/ai/skills/supabase/SKILL.md`)
- The task is UI-only and does not change auth behavior

## Core Rules

1. Use `@supabase/ssr` patterns for App Router integration.
2. Use `@/lib/supabase/server` for server-side code and `@/lib/supabase/client` for client-side code.
3. Use middleware to refresh and enforce session state on protected routes.
4. Do not manually store or forward auth tokens in client code.
5. Use Server Actions (or secure route handlers) for privileged auth operations.
6. Maintain RLS assumptions; do not bypass policy boundaries.

## Workflow

1. Identify execution boundary first (server component, client component, middleware, action, or route handler).
2. Ensure the correct Supabase client is used for that boundary.
3. Verify middleware coverage for protected routes.
4. Verify callback handling exchanges auth code/session correctly.
5. Validate auth checks before sensitive reads/writes.
6. Verify end-to-end login/logout/session refresh behavior.

## Checklist

- [ ] Server code imports `@/lib/supabase/server`
- [ ] Client code imports `@/lib/supabase/client`
- [ ] Protected paths are covered by auth middleware
- [ ] Callback route/session exchange is correctly handled
- [ ] No service role keys in client-side code
- [ ] No manual token persistence logic added

## Common Anti-Patterns

- Using browser clients in server actions
- Using server clients in client components
- Calling `getSession` blindly in server render paths without user validation
- Storing JWTs manually in localStorage/cookies

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.