What problem does it solve? Securing a Next.js application with Clerk involves many distinct patterns—middleware route protection, Server Action authorization, API route 401/403 handling, user-scoped caching, and JWT verification—and getting any of them wrong creates security holes or confusing bugs like undefined userId or cross-user cache leaks. ## Core Features & Use Cases - Server vs Client Auth Guidance: Explains when to use await auth() from @clerk/nextjs/server versus client hooks like useAuth() and useUser(), including the <Show> component for conditional rendering. - Middleware Strategies: Provides public-first and protected-first clerkMiddleware configurations with createRouteMatcher, permission-gated routes, token-based protection, and session task handling. - Server Actions, API Routes & Caching: Shows how to protect mutations, return correct 401 vs 403 status codes, and build user-scoped unstable_cache keys that prevent data leaking between users. - JWT & Session Tokens: Covers getToken() with JWT templates for third-party APIs like Hasura and Supabase, plus manual JWT verification with @clerk/backend or jsonwebtoken for standalone servers. - Use Case: You need to protect all routes under /dashboard, secure a Server Action that creates posts, and call an external GraphQL API with a custom Clerk JWT—this Skill provides the exact patterns for each. ## Quick Start Ask the AI to protect your Next.js dashboard routes with Clerk middleware and convert a client component using useUser into a server component using await auth().