Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync Use when: adding authentication, clerk auth, user authentication, sign in, sign up.
Add this skill
npx mdskills install sickn33/clerk-authProvides clear patterns for Clerk auth but lacks actionable instructions and edge case details
1---2name: clerk-auth3description: "Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync Use when: adding authentication, clerk auth, user authentication, sign in, sign up."4source: vibeship-spawner-skills (Apache 2.0)5---67# Clerk Authentication89## Patterns1011### Next.js App Router Setup1213Complete Clerk setup for Next.js 14/15 App Router.1415Includes ClerkProvider, environment variables, and basic16sign-in/sign-up components.1718Key components:19- ClerkProvider: Wraps app for auth context20- <SignIn />, <SignUp />: Pre-built auth forms21- <UserButton />: User menu with session management222324### Middleware Route Protection2526Protect routes using clerkMiddleware and createRouteMatcher.2728Best practices:29- Single middleware.ts file at project root30- Use createRouteMatcher for route groups31- auth.protect() for explicit protection32- Centralize all auth logic in middleware333435### Server Component Authentication3637Access auth state in Server Components using auth() and currentUser().3839Key functions:40- auth(): Returns userId, sessionId, orgId, claims41- currentUser(): Returns full User object42- Both require clerkMiddleware to be configured434445## ⚠️ Sharp Edges4647| Issue | Severity | Solution |48|-------|----------|----------|49| Issue | critical | See docs |50| Issue | high | See docs |51| Issue | high | See docs |52| Issue | high | See docs |53| Issue | medium | See docs |54| Issue | medium | See docs |55| Issue | medium | See docs |56| Issue | medium | See docs |57
Full transparency — inspect the skill content before installing.