首页/ AI 技能 / @skilllib/skill-2014279394536140801
Skill站外收录 @skilllib/skill-2014279394536140801

clerk-auth

提供 Clerk 认证体系的完整集成方案,覆盖 Next.js App Router 初始化、中间件路由保护、服务端组件身份校验及组织与用户数据同步,支持安全的登录、注册与会话管理。

0.0 (0) 172 次安装 原作者 编程导航
收录于 2026-01-22

Skills.MD

# Clerk Authentication ## Patterns ### Next.js App Router Setup Complete Clerk setup for Next.js 14/15 App Router. Includes ClerkProvider, environment variables, and basic sign-in/sign-up components. Key components: - ClerkProvider: Wraps app for auth context - <SignIn />, <SignUp />: Pre-built auth forms - <UserButton />: User menu with session management ### Middleware Route Protection Protect routes using clerkMiddleware and createRouteMatcher. Best practices: - Single middleware.ts file at project root - Use createRouteMatcher for route groups - auth.protect() for explicit protection - Centralize all auth logic in middleware ### Server Component Authentication Access auth state in Server Components using auth() and currentUser(). Key functions: - auth(): Returns userId, sessionId, orgId, claims - currentUser(): Returns full User object - Both require clerkMiddleware to be configured ## ⚠️ Sharp Edges | Issue | Severity | Solution | |-------|----------|----------| | Issue | critical | See docs | | Issue | high | See docs | | Issue | high | See docs | | Issue | high | See docs | | Issue | medium | See docs | | Issue | medium | See docs | | Issue | medium | See docs | | Issue | medium | See docs |

评论 0

还没有评论,来抢沙发。