What problem does it solve?
Provides clear, secure patterns to prevent unauthorized access, session leaks, and incorrect client/server auth usage in Next.js applications using Clerk.
Core Features & Use Cases
- Server vs Client Auth Guidance: Explains when to use await auth() and server imports versus client hooks to avoid undefined user state and flashing UI.
- Middleware & Route Protection: Patterns for public-first and protected-first middleware strategies to centrally protect dashboards, APIs, and routes.
- Server Actions, Token Handling & Caching: Shows how to protect Server Actions, use getToken for external APIs, manually verify JWTs, and implement user- or org-scoped caching to avoid data leakage.
- Use Case: Convert a client-side dashboard that flashes unauthenticated content into a server component that uses auth() for seamless, secure rendering and correct caching per user.
Quick Start
Apply the clerk-nextjs-patterns guidance to replace client-side auth hooks with server-side auth(), add middleware protections for your protected routes, and ensure cache keys include userId or orgId.