技能 编程开发 Next.js 与 Supabase 认证

Next.js 与 Supabase 认证

v20260330
nextjs-supabase-auth
指导在 Next.js App Router 中集成 Supabase Auth,涵盖中间件、服务端操作、令牌处理和受保护路由,保障认证流程安全。
获取技能
292 次下载
概览

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

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

信息
Category 编程开发
Name nextjs-supabase-auth
版本 v20260330
大小 1.49KB
更新时间 2026-03-30
语言