跳到正文
Skillpedia
安全33k · #8784

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/nextjs-supabase-auth/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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:

  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

常见问题

它使用哪个 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.

repo: davila7/claude-code-templates

热度

GitHub 星标
33k
排名
#8784
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能