Skip to content
Skillpedia
Security33k · #8737

clerk-auth

What it does

This skill gives your AI agent patterns for adding Clerk sign-in to an app. It is for developers who want login, sign-up and route protection with Clerk.

When to use it

  • ✓When you want to add sign-in or sign-up to a Next.js app with Clerk.
  • ✓When you need to protect certain pages so only signed-in users can open them.
  • ✓When you want to get the current user in a server component.

Skill link

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clerk-auth/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clerk-auth/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Add Clerk sign-in to my Next.js app and protect the dashboard pages.”

5 new skills a week. 1 minute to read.

How it works

The agent sets up Clerk's provider, middleware and ready-made sign-in components. It then uses helper functions to read the signed-in user on the server and block protected routes.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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
FAQ

Which Next.js versions are covered?

The skill covers Next.js 14 and 15 with the App Router.

What ready-made components are there?

It includes SignIn, SignUp and UserButton components.

Does it cover webhooks?

Yes, the skill covers webhooks and user sync as well as organizations.

Details

Original description by the author

Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync Use when: adding authentication, clerk auth, user authentication, sign in, sign up.

repo: davila7/claude-code-templates

Popularity

GitHub stars
33k
Ranking position
#8737
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills