跳到正文
TakoAPI
返回技能列表

sr-next-clerk-expert

由 michaelmonetized 提供

Web & Frontend Development
—暂无评分
你的评分

简介

Senior-level Clerk authentication expertise for Next.js 15/16+ applications.

描述

该技能的功能

Provides senior-level patterns for implementing Clerk authentication in Next.js 15/16+ apps. Covers route protection, middleware configuration, client vs server auth boundaries, and integration with Convex and Stripe. Includes a set of rules that prevent common auth failures like 500 errors, infinite redirects, and handshake loops.

Encodes hard-won production rules that are not obvious from Clerk's official docs, preventing outages caused by calling auth() on public pages or skipping ClerkLoaded wrappers.

何时使用

  • Protecting dashboard routes while keeping marketing pages public
  • Migrating from middleware.ts to proxy.ts for Next.js 16+
  • Debugging Clerk handshake redirects and 500 errors in production
  • Adding Stripe billing flows to an existing Clerk-authenticated app
  • Syncing Clerk users to a Convex database via webhooks

示例工作流

输入

User asks: How do I protect my dashboard routes but keep the homepage public in Next.js 16+?

智能体
  1. 1

    Creates app/(private)/ route group containing dashboard and settings pages

  2. 2

    Generates proxy.ts using clerkMiddleware that only protects /(private)(.*) routes

  3. 3

    Creates app/(private)/layout.tsx that calls auth() and redirects unauthenticated users

  4. 4

    Updates app/page.tsx to use SignedIn/SignedOut inside ClerkLoaded instead of calling auth()

  5. 5

    Provides verification checklist to test anonymous access before deploying

输出

Working route protection setup where public pages remain static and only private routes require authentication

前置要求

  • CLERK_SECRET_KEY environment variable (from Clerk Dashboard)
  • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY environment variable (from Clerk Dashboard)
  • Clerk account

安装

clawhub install michaelmonetized/sr-next-clerk-expert

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接