Skip to content

Clerk authentication patterns for Next.js App Router, middleware route protection, and server-side user access.

CCM score
53 of 100
skills.sh installs
220
GitHub stars
34.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers Next.js 14 and 15 App Router setup with ClerkProvider and environment variable configuration
  • Includes pre-built <SignIn />, <SignUp />, and <UserButton /> components for sign-in, sign-up, and session menus
  • Enforces single-file route protection in middleware.ts using createRouteMatcher and auth.protect()
  • Provides auth() and currentUser() for reading session and user data in Server Components

Install

$ npx -y skills add davila7/claude-code-templates --skill clerk-auth -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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
  • , : Pre-built auth forms
  • : 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

Details

Repository
github.com/davila7/claude-code-templates
Categories
Backend & APIs, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What does the clerk-auth skill do?

The clerk-auth skill gives Claude Code expert patterns for Clerk authentication, covering Next.js App Router setup with ClerkProvider and sign-in or sign-up components. It also covers middleware route protection with clerkMiddleware and createRouteMatcher, plus organizations, webhooks, and user sync.

How do I install clerk-auth?

Run npx -y skills add davila7/claude-code-templates --skill clerk-auth -y in your project. Once installed, the agent gets Clerk auth patterns for adding authentication, sign in, and sign up.

Where does clerk-auth stand in the Backend & APIs category?

clerk-auth is listed in the Backend & APIs category on Claude Marketplaces, alongside entra-app-registration, neon, firebase-basics, firebase-auth-basics, and workers-best-practices. It focuses specifically on Clerk, covering server component auth using auth() and currentUser() as well as middleware.

More from davila7/claude-code-templates

All 398

Similar to Clerk Auth

More Backend & APIs