nextjs-supabase-auth
它能做什么
这个技能为你的 AI 智能体提供为 Next.js 应用添加 Supabase 身份验证的专家模式。适合使用 Supabase 构建登录、受保护页面和会话的开发者。
适用场景
- ✓当你为 Next.js App Router 应用添加 Supabase 登录或注册时。
- ✓当你需要保护页面,使只有已登录用户才能打开时。
- ✓当你想为 Supabase 登录设置 OAuth 回调路由时。
技能链接
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/nextjs-supabase-auth/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的 Next.js 应用添加 Supabase 邮箱登录,并保护仪表盘路由。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为每个上下文创建配置正确的 Supabase 客户端,在中间件中刷新会话,并处理 OAuth 回调,以将授权码交换为会话。
技术内容(原始 SKILL.md)
作者在 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:
- Use @supabase/ssr for App Router integration
- Handle tokens in middleware for protected routes
- Never expose auth tokens to client unnecessarily
- Use Server Actions for auth operations when possible
- 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
常见问题
它使用哪个 Supabase 包?
它使用 @supabase/ssr 包来集成 App Router。
令牌应该在哪里处理?
该技能说应在中间件中处理令牌,并避免将其暴露给客户端。
它警告哪些错误?
它警告不要在服务端组件中使用 getSession,也不要手动存储令牌。
详情
作者的原始描述
Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.
热度
- GitHub 星标
- 33k
- 排名
- #8784
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
owasp-security
33k教你的智能体掌握面向网页应用、API、移动端、容器和 AI 智能体的 OWASP 安全指南,以便发现常见弱点并提出修复建议。
agent-management
33k让你的智能体使用 AI Maestro 命令行工具创建、列出、休眠、唤醒、重命名和删除 AI 智能体,管理每个智能体的生命周期。
agent-messaging
33k让你的智能体使用智能体消息协议,在 AI 智能体之间发送、接收和回复带签名的消息,大部分在你自己的电脑上完成。
docs-search
33k让你的智能体搜索自动生成的代码文档,查找函数签名、类定义和注释,从而在修改代码之前核对真实的 API。