davila7 avatar

Nextjs Supabase Auth

This handles the tricky parts of wiring up Supabase authentication in Next.js App Router projects, specifically the server/client boundary issues that trip people up. It's built around @supabase/ssr and focuses on middleware-based route protection, proper token handling, and OAuth callbacks. The skill pushes you toward Server Actions for auth operations and away from common mistakes like calling getSession in Server Components or manually storing tokens. Useful when you're setting up login flows, protected routes, or just need the auth boilerplate done correctly the first time instead of debugging cookie issues at midnight.

skills.sh installs
410
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill nextjs-supabase-auth --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Categories
Frontend Development, Backend & APIs, Security, Databases
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1questfortech-investments avatarreact-vite-expertquestfortech-investments/claude-code-skillsComplete React + Vite expertise for building optimized, scalable applications. Covers project architecture, folder structure, component patterns, performance op405skills.sh installs
2hairyf avatarreact-native-reusableshairyf/skillsAgent skill for React Native Reusables — shadcn-style components for React Native (Expo) with Nativewind/Uniwind, RN Primitives, and CLI-driven scaffolding.387skills.sh installs
3mrgoonie avatarfrontend-dev-guidelinesmrgoonie/claudekit-skillsFrontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with fe377skills.sh installs
4bobmatnyc avatarnextjs-corebobmatnyc/claude-mpm-skillsCore Next.js patterns for App Router development including Server Components, Server Actions, route handlers, data fetching, and caching strategies357skills.sh installs
5bobmatnyc avatarsveltebobmatnyc/claude-mpm-skillsSvelte 5 - Reactive UI framework with compiler magic, Runes API, SvelteKit full-stack framework, SSR/SSG, minimal JavaScript352skills.sh installs
6bobmatnyc avatarhono-jsxbobmatnyc/claude-mpm-skillsHono JSX - server-side rendering, streaming, async components, and HTML generation patterns347skills.sh installs