What problem does it solve?
This Skill provides comprehensive solutions for implementing secure authentication and authorization in Next.js App Router applications, covering both managed (Clerk) and self-hosted (Better Auth) options.
Core Features & Use Cases
- Authentication Flows: Implement sign-up, sign-in, and session management.
- Route Protection: Secure routes using middleware for both Clerk and Better Auth.
- OAuth Integration: Easily add social login providers like GitHub and Google.
- Server-Side Access: Access user session data securely in Server Components, Actions, and API Routes.
- Webhook Handling: Synchronize user data with Clerk webhooks.
- Security Best Practices: Addresses potential vulnerabilities like App Router cache bypass.
- Use Case: Secure a new SaaS application by implementing email/password sign-up, Google OAuth, and protecting all routes under
/dashboard with middleware.
Quick Start
Install Clerk and add basic authentication to your Next.js app by wrapping your layout with ClerkProvider and setting up middleware to protect routes.