clerk-nextjs-auth
Installation
SKILL.md
Clerk Next.js Auth
Overview
Use this skill for Clerk integrations in Next.js projects, especially App Router projects using @clerk/nextjs. Focus on correct file placement, protected-route coverage, server/client boundaries, and modern Clerk middleware behavior.
Quick Reference
| Need | Preferred Clerk primitive |
|---|---|
| Wrap app with auth context and prebuilt components | ClerkProvider |
| Read auth state in App Router server code | auth() from @clerk/nextjs/server |
| Read current user object in App Router server code | currentUser() from @clerk/nextjs/server |
| Protect routes before rendering | clerkMiddleware() + auth.protect() |
| Group protected/public routes | createRouteMatcher() |
| Pages Router API auth | getAuth(req) |
| Administrative Backend API calls | clerkClient from server-only code |
| Client UI state | useUser(), useAuth(), useClerk() |