This project is deployed on Vercel.
Visit next-OAuth app
🛠Tech Stack & Resources
🔗 Next.js 15
🔗 Resend (for emails)
🔗 Node.js
🔗 Shadcn UI
🔗 Clerk
🔗 Sonner
🔗 Zod for validation
🔗 Prisma or Prisma in Auth.js
🔗 Neon as database
🔑 Key Features
-
Next-auth v5 (Auth.js) authentication
-
Server Actions in Next.js 15
-
Credentials Provider (email/password login)
-
OAuth Provider (Social login with Google & GitHub)
-
Forgot Password Functionality
-
Email Verification
-
Two-Factor Authentication (2FA)
-
User Roles (Admin & User)
-
Login and Register Components (Redirect or Modal)
-
Forgot Password, Verification, and Error Components
-
Login and Logout Buttons
-
Role-Based Access Control (Role Gate)
-
Middleware Protection using Next.js middleware
-
Extended Session Handling with NextAuth callbacks
-
Custom Hooks:
* useCurrentUser, * useRole
-
Utilities:
* currentUser, * currentRole
-
Server and Client Component Examples
-
Admin-Only Content Rendering using RoleGate
-
Protect API Routes and Server Actions (Admins Only)
-
Change Email (with re-verification)
-
Change Password (confirm old password)
-
Enable/Disable Two-Factor Authentication (2FA)
-
Change User Role (for development/testing purposes)
📚 Learning Goals
- Learn how to set up OAuth login with Credentials, Google and GitHub
- Implement authentication flows (login, registration, email verification, password reset)
- Protect pages, components, APIs, and server actions
- Use Next.js server actions with Auth.js
- Understand and extend next-auth sessions and callbacks
- Add Two-Factor Authentication (2FA)
- Manage user roles (Admin/User)
- Explore middleware to protect routes
- Explore advanced UI flows with Shadcn UI