Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

nextjs-supabase-authNext.js Supabase auth 开发

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

109,296

周安装

4,578

GitHub Stars

35,738

下载量

38,272
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nextjs-supabase-auth(Next.js Supabase auth 开发)
来源仓库:https://github.com/sickn33/antigravity-awesome-skills
仓库路径:skills/nextjs-supabase-auth
安装命令:
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill nextjs-supabase-auth
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill nextjs-supabase-auth

简介

Next.js App Router 的 Supabase Auth 集成与基于中间件的会话管理。

  • 使用 @supabase/ssr 处理服务器/客户端身份验证边界,通过中间件保护路由并管理基于 cookie 的会话
  • 提供 OAuth 回调模式、用于身份验证操作的服务器操作以及跨服务器和客户端组件的正确令牌处理
  • 包括要避免的反模式:服务器组件中的 getSession、未监听的客户端身份验证状态和手动令牌存储

SKILL.md

Next.js + Supabase Auth

Expert integration of Supabase Auth with Next.js App Router

Capabilities

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

Prerequisites

  • Required skills: nextjs-app-router, supabase-backend

Patterns

Supabase Client Setup

Create properly configured Supabase clients for different contexts

When to use: Setting up auth in a Next.js project

// lib/supabase/client.ts (Browser client) 'use client' import {createBrowserClient} from '@supabase/ssr'

export function createClient() {return createBrowserClient(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!)}

// lib/supabase/server.ts (Server client) import {createServerClient} from '@supabase/ssr' import {cookies} from 'next/headers'

export async function createClient() {const cookieStore = await cookies() return createServerClient(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, {cookies: {getAll() {return cookieStore.getAll()}, setAll(cookiesToSet) {cookiesToSet.forEach(({name, value, options}) => {cookieStore.set(name, value, options)})},},})}

Auth Middleware

Protect routes and refresh sessions in middleware

When to use: You need route protection or session refresh

// middleware.ts import {createServerClient} from '@supabase/ssr' import {NextResponse, type NextRequest} from 'next/server'

export async function middleware(request: NextRequest) {let response = NextResponse.next({request})

const supabase = createServerClient(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, {cookies: {getAll() {return request.cookies.getAll()}, setAll(cookiesToSet) {cookiesToSet.forEach(({name, value, options}) => {response.cookies.set(name, value, options)})},},})

// Refresh session if expired const {data: {user}} = await supabase.auth.getUser()

// Protect dashboard routes if (request.nextUrl.pathname.startsWith('/dashboard') &&!user) {return NextResponse.redirect(new URL('/login', request.url))}

return response}

export const config = {matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],}

Auth Callback Route

Handle OAuth callback and exchange code for session

When to use: Using OAuth providers (Google, GitHub, etc.)

// app/auth/callback/route.ts import {createClient} from '@/lib/supabase/server' import {NextResponse} from 'next/server'

export async function GET(request: Request) {const {searchParams, origin} = new URL(request.url) const code = searchParams.get('code') const next = searchParams.get('next')?? '/'

if (code) {const supabase = await createClient() const {error} = await supabase.auth.exchangeCodeForSession(code) if (!error) {return NextResponse.redirect(${origin}${next})}}

return NextResponse.redirect(${origin}/auth/error)}

Server Action Auth

Handle auth operations in Server Actions

When to use: Login, logout, or signup from Server Components

// app/actions/auth.ts 'use server' import {createClient} from '@/lib/supabase/server' import {redirect} from 'next/navigation' import {revalidatePath} from 'next/cache'

export async function signIn(formData: FormData) {const supabase = await createClient() const {error} = await supabase.auth.signInWithPassword({email: formData.get('email') as string, password: formData.get('password') as string,})

if (error) {return {error: error.message}}

revalidatePath('/', 'layout') redirect('/dashboard')}

export async function signOut() {const supabase = await createClient() await supabase.auth.signOut() revalidatePath('/', 'layout') redirect('/')}

Get User in Server Component

Access the authenticated user in Server Components

When to use: Rendering user-specific content server-side

// app/dashboard/page.tsx import {createClient} from '@/lib/supabase/server' import {redirect} from 'next/navigation'

export default async function DashboardPage() {const supabase = await createClient() const {data: {user}} = await supabase.auth.getUser()

if (!user) {redirect('/login')}

return (Welcome, {user.email})}

Validation Checks

Using getSession() for Auth Checks

Severity: ERROR

Message: getSession() doesn't verify the JWT. Use getUser() for secure auth checks.

Fix action: Replace getSession() with getUser() for security-critical checks

OAuth Without Callback Route

Severity: ERROR

Message: Using OAuth but missing callback route at app/auth/callback/route.ts

Fix action: Create app/auth/callback/route.ts to handle OAuth redirects

Browser Client in Server Context

Severity: ERROR

Message: Browser client used in server context. Use createServerClient instead.

Fix action: Import and use createServerClient from @supabase/ssr

Protected Routes Without Middleware

Severity: WARNING

Message: No middleware.ts found. Consider adding middleware for route protection.

Fix action: Create middleware.ts to protect routes and refresh sessions

Hardcoded Auth Redirect URL

Severity: WARNING

Message: Hardcoded localhost redirect. Use origin for environment flexibility.

Fix action: Use window.location.origin or process.env.NEXT_PUBLIC_SITE_URL

Auth Call Without Error Handling

Severity: WARNING

Message: Auth operation without error handling. Always check for errors.

Fix action: Destructure {data, error} and handle error case

Auth Action Without Revalidation

Severity: WARNING

Message: Auth action without revalidatePath. Cache may show stale auth state.

Fix action: Add revalidatePath('/', 'layout') after auth operations

Client-Only Route Protection

Severity: WARNING

Message: Client-side route protection shows flash of content. Use middleware.

Fix action: Move protection to middleware.ts for better UX

Collaboration

Delegation Triggers

  • database|rls|queries|tables -> supabase-backend (Auth needs database layer)
  • route|page|component|layout -> nextjs-app-router (Auth needs Next.js patterns)
  • deploy|production|vercel -> vercel-deployment (Auth needs deployment config)
  • ui|form|button|design -> frontend (Auth needs UI components)

Full Auth Stack

Skills: nextjs-supabase-auth, supabase-backend, nextjs-app-router, vercel-deployment

Workflow:

1. Database setup (supabase-backend)
2. Auth implementation (nextjs-supabase-auth)
3. Route protection (nextjs-app-router)
4. Deployment config (vercel-deployment)

Protected SaaS

Skills: nextjs-supabase-auth, stripe-integration, supabase-backend

Workflow:

1. User authentication (nextjs-supabase-auth)
2. Customer sync (stripe-integration)
3. Subscription gating (supabase-backend)

Related Skills

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

When to Use

  • User mentions or implies: supabase auth next
  • User mentions or implies: authentication next.js
  • User mentions or implies: login supabase
  • User mentions or implies: auth middleware
  • User mentions or implies: protected route
  • User mentions or implies: auth callback
  • User mentions or implies: session management

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.61%
按下载量换算11,715

Antigravity

21.23%
按下载量换算8,125

OpenCode

16.54%
按下载量换算6,330

Gemini CLI

12.65%
按下载量换算4,841

Cursor

7%
按下载量换算2,679

Codex

3.69%
按下载量换算1,412

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills