What problem does it solve? Securing a Next.js application with Clerk involves many decisions—server vs client auth APIs, middleware strategies, Server Action protection, and user-scoped caching—and mistakes like missing awaits or unscoped cache keys cause auth bugs and data leaks. ## Core Features & Use Cases - Server vs Client Auth Guidance: Explains when to use await auth() from @clerk/nextjs/server versus hooks like useAuth() and useUser(), with Core 2 compatibility callouts. - Middleware & Route Protection: Covers public-first and protected-first middleware strategies, permission-gated routes, token-based protection for machine APIs, and 401 vs 403 handling in API routes. - Server Actions, Caching & JWTs: Shows how to protect Server Actions, build user-scoped unstable_cache keys, fetch custom JWTs with getToken() templates, and manually verify Clerk tokens on standalone servers. - Use Case: Convert a client component using useUser with a redirect useEffect into a server component using await auth(), eliminating the flash of unauthenticated content. ## Quick Start Ask the assistant to protect your Next.js dashboard routes and API endpoints with Clerk middleware and server-side auth checks.