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 vvedantb

Provides guidance for Clerk authentication in Next.js apps, covering middleware, Server Actions, caching, and JWT handling. It is for developers who build Next.js applications with Clerk.

  • Score 67
  • 101 stars
  • MIT
  • 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/vvedantb/eva /tmp/eva && mkdir -p ~/.claude/skills && cp -r /tmp/eva/.agents/skills/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 skill is a reference for adding Clerk authentication to Next.js projects. It lists which reference file to read for each task, such as choosing server or client auth, configuring middleware, protecting Server Actions, returning 401 or 403 from API routes, and caching auth data per user. It also explains conditional rendering with the Show component, including feature, permission, plan, and role checks for B2B apps.

The skill covers session tokens and custom JWTs. It shows how to pass a JWT template token from getToken() to external APIs and how to verify Clerk tokens manually in standalone API servers. It also lists common pitfalls, such as a missing await on auth(), and notes differences for Clerk Core 2. It is aimed at developers who already know the basic Clerk setup and need patterns for production Next.js code.

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

What it can do

  • Server vs client authExplains when to use await auth() in server code and the useAuth() hook in client components.
  • Middleware strategiesCovers public-first and protected-first middleware, using proxy.ts or middleware.ts depending on Next.js version.
  • Server Action protectionShows how to check auth at the start of Server Actions so mutations cannot bypass it.
  • API route authExplains returning 401 for unauthenticated requests and 403 for missing permission.
  • User-scoped cachingShows how to include userId in cache keys so one user does not receive another user's data.
  • Conditional renderingUses the Show component to gate content by sign-in state, feature, permission, plan, or role.
  • JWT templates with getToken()Passes custom JWTs from Clerk JWT templates to third-party APIs on the server or client.
  • Manual JWT verificationVerifies 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 for manual JWT verification
  • Next.js project
  • Clerk Next.js SDK

Try asking

  • Show me how to protect a Next.js Server Action with Clerk auth.
  • Write a cached data fetch that scopes the cache key to the signed-in userId.
  • Add a permission-gated button using Clerk's Show component in my Next.js page.

Good to know

  • Core 2 does not support isAuthenticated, sessionStatus, or the Show component.
  • Feature and plan checks in Show require Core 3.
  • Middleware file is proxy.ts in newer Next.js versions and middleware.ts in Next.js 15 and earlier.

Security check

A

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

Checked automatically: .agents/skills/clerk-nextjs-patterns/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: WebFetch

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 work with Clerk Core 2?

It includes Core 2 callouts for each difference. Core 2 lacks isAuthenticated, sessionStatus, and the Show component, so the skill says to use !!userId, SignedIn and SignedOut, or Protect instead.

How do I verify Clerk tokens in an API server without Clerk middleware?

The skill shows verifying the token with verifyToken from @clerk/backend using CLERK_JWT_KEY, or with jsonwebtoken using CLERK_PEM_PUBLIC_KEY. Tokens come from the Authorization header or the __session cookie.

Why does auth() return undefined in my Server Component?

The source says this usually happens because auth() is missing await. Calling await auth() fixes it, since auth() is async in server code.

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 MIT licence. The service it connects to may have its own pricing.

Is clerk-nextjs-patterns safe to use?

It scores 67 of 100. Grades: maintenance A, licence A, quality B. 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.