← ClaudeAtlas

clerk-nextjs-patternslisted

Advanced Next.js patterns - middleware, Server Actions, caching with Clerk.
FJRG2007/enigma · ★ 2 · Web & Frontend · score 72
Install: claude install-skill FJRG2007/enigma
# Next.js Patterns > **Version**: Check `package.json` for the SDK version — see `clerk` skill for the version table. Core 2 differences are noted inline with `> **Core 2 ONLY (skip if current SDK):**` callouts. For basic setup, see `clerk-setup` skill. ## What Do You Need? | Task | Reference | |------|-----------| | Server vs client auth (`auth()` vs hooks) | references/server-vs-client.md | | Configure middleware (public-first vs protected-first) | references/middleware-strategies.md | | Protect Server Actions | references/server-actions.md | | API route auth (401 vs 403) | references/api-routes.md | | Cache auth data (user-scoped caching) | references/caching-auth.md | ## References | Reference | Description | |-----------|-------------| | `references/server-vs-client.md` | `await auth()` vs hooks | | `references/middleware-strategies.md` | Public-first vs protected-first, `proxy.ts` (Next.js <=15: `middleware.ts`) | | `references/server-actions.md` | Protect mutations | | `references/api-routes.md` | 401 vs 403 | | `references/caching-auth.md` | User-scoped caching | ## Mental Model Server vs Client = different auth APIs: - **Server**: `await auth()` from `@clerk/nextjs/server` (async!) - **Client**: `useAuth()` hook from `@clerk/nextjs` (sync) Never mix them. Server Components use server imports, Client Components use hooks. Key properties from `auth()`: - `isAuthenticated` — boolean, replaces the `!!userId` pattern - `sessionStatus` — `'active'` | `'pending'`,