Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

clerk-nextjs-patterns

Skill by midudev

Covers advanced Next.js patterns with Clerk, including route protection, Server Actions, user-scoped caching and JWT verification. Aimed at developers building authenticated Next.js apps with Clerk.

  • Score 85
  • 7k stars
  • NOASSERTION
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install clerk-nextjs-patterns

Built from the published package, never by AI.

git clone --depth 1 https://github.com/midudev/autoskills /tmp/autoskills && mkdir -p ~/.claude/skills && cp -r /tmp/autoskills/packages/autoskills/skills-registry/clerk-nextjs-patterns ~/.claude/skills/clerk-nextjs-patterns

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install clerk-nextjs-patterns in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This agent skill gives an AI assistant reference guidance for using Clerk authentication in Next.js. It explains when to use the server auth() function versus client hooks, and how to protect pages, Route Handlers and Server Actions with auth.protect(). It also covers 401 versus 403 responses, user-scoped caching of auth data, and conditional rendering with the Show component for features, plans, roles and permissions.

The skill also shows how to pass Clerk JWT templates to external APIs with getToken(), read session data with useSession(), and verify tokens manually in standalone API servers using @clerk/backend or jsonwebtoken. It lists common pitfalls, such as a missing await on auth(). It is for developers who already use Clerk with Next.js and need the more advanced patterns. The source notes that basic setup is covered by a separate clerk-setup skill.

Written from the project's SKILL.md and checked against it.

What it can do

  • Server vs client authExplains await auth() from @clerk/nextjs/server versus the useAuth() hook in Client Components.
  • Route protectionShows calling auth.protect() in each page, Route Handler and Server Function, with a bare clerkMiddleware().
  • Server Action protectionCovers checking auth at the start of Server Actions so mutations are not left unprotected.
  • API route authExplains returning 401 for not signed in and 403 for missing permission.
  • User-scoped cachingExplains including userId in cache keys so one user's auth data is not returned to another.
  • Conditional renderingShows the Show component for sign-in state, feature, plan, role and permission checks.
  • getToken for external APIsShows passing a Clerk JWT template token to third-party services such as Hasura or Supabase.
  • Manual JWT verificationShows verifying Clerk session tokens in standalone API servers with verifyToken or jsonwebtoken.

What you need

  • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
  • CLERK_SECRET_KEY
  • CLERK_JWT_KEY or CLERK_PEM_PUBLIC_KEY (only for manual JWT verification)
  • @clerk/nextjs SDK

Try asking

  • Protect my Next.js Server Action so only signed-in users can run it
  • Show how to call an external API with a Clerk JWT template token
  • Cache user-specific data in Next.js without leaking it between users

Good to know

  • createRouteMatcher is deprecated in @clerk/nextjs 7 and should not be added to new code.
  • isAuthenticated and sessionStatus are not available in Core 2.
  • Show feature and plan variants require Core 3.
  • Manual JWT verification is only needed for standalone API servers without Clerk middleware.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: packages/autoskills/skills-registry/clerk-nextjs-patterns/SKILL.md, packages/autoskills/skills-registry/clerk-nextjs-patterns/templates/nextjs-basic-auth/proxy.ts. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: WebFetch

  • SKILL.md9 KB
  • evals/evals.json5 KB
  • references/api-routes.md1 KB
  • references/caching-auth.md1 KB
  • references/middleware-strategies.md7 KB
Show all 12 files
  • references/server-actions.md2 KB
  • references/server-vs-client.md2 KB
  • templates/nextjs-basic-auth/app/layout.tsx565 B
  • templates/nextjs-basic-auth/app/page.tsx58 B
  • templates/nextjs-basic-auth/package.json353 B
  • templates/nextjs-basic-auth/proxy.ts280 B
  • templates/nextjs-basic-auth/tsconfig.json576 B

Alternatives to clerk-nextjs-patterns

All alternatives →
openclaw-github-repo-commandersickn33
94

Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.

AAA Skill 50k
gradiogradio-app
94

Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.

AAA Skill 44k
hig-components-menussickn33
94

Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.

AAA Skill 50k
fastapi-templateswshobson
94

Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.

AAA Skill 43k
appfunctionsandroid
94

Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.

AAA Skill 11k
agent-qa-authoringsickn33
94

Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.

AAA Skill 50k

Compare with openclaw-github-repo-commander, gradio or hig-components-menus

clerk-nextjs-patterns: common questions

Does this skill cover basic Clerk setup in Next.js?

No. The source says basic setup is covered by the separate clerk-setup skill.

Should I use createRouteMatcher to protect routes?

No. The source says it is deprecated in @clerk/nextjs 7 and should not be added. Existing uses can stay working while you follow the migration guide.

How do I pass Clerk auth to an external API?

The skill shows using getToken() with a JWT template defined in the Clerk dashboard, then sending the token as a Bearer header.

How do I install clerk-nextjs-patterns?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is clerk-nextjs-patterns free?

The code is published under the NOASSERTION licence. The service it connects to may have its own pricing.

Is clerk-nextjs-patterns safe to use?

It scores 85 of 100. Grades: maintenance A, licence F, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to clerk-nextjs-patterns?

Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.

clerk-nextjs-patterns Install

Add to stack

Loading.