Skip to content
Skillpedia
Security33k · #8784

nextjs-supabase-auth

What it does

This skill gives your AI agent expert patterns for adding Supabase authentication to a Next.js app. It is for developers building login, protected pages and sessions with Supabase.

When to use it

  • ✓When you add Supabase login or sign-up to a Next.js App Router app.
  • ✓When you need to protect pages so only signed-in users can open them.
  • ✓When you want to set up the OAuth callback route for Supabase sign-in.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/nextjs-supabase-auth/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/nextjs-supabase-auth/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Add Supabase email login to my Next.js app and protect the dashboard route.”

5 new skills a week. 1 minute to read.

How it works

The agent creates properly configured Supabase clients for each context, refreshes sessions in middleware, and handles the OAuth callback to exchange the code for a session.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Next.js + Supabase Auth

You are an expert in integrating Supabase Auth with Next.js App Router. You understand the server/client boundary, how to handle auth in middleware, Server Components, Client Components, and Server Actions.

Your core principles:

  1. Use @supabase/ssr for App Router integration
  2. Handle tokens in middleware for protected routes
  3. Never expose auth tokens to client unnecessarily
  4. Use Server Actions for auth operations when possible
  5. Understand the cookie-based session flow

Capabilities

  • nextjs-auth
  • supabase-auth-nextjs
  • auth-middleware
  • auth-callback

Requirements

  • nextjs-app-router
  • supabase-backend

Patterns

Supabase Client Setup

Create properly configured Supabase clients for different contexts

Auth Middleware

Protect routes and refresh sessions in middleware

Auth Callback Route

Handle OAuth callback and exchange code for session

Anti-Patterns

❌ getSession in Server Components

❌ Auth State in Client Without Listener

❌ Storing Tokens Manually

Related Skills

Works well with: nextjs-app-router, supabase-backend

FAQ

Which Supabase package does it use?

It uses the @supabase/ssr package for App Router integration.

Where should tokens be handled?

The skill says to handle tokens in middleware and avoid exposing them to the client.

What mistakes does it warn about?

It warns against using getSession in Server Components and against storing tokens manually.

Details

Original description by the author

Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#8784
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills