Next Auth V5 - Advanced Guide (2024)
โญ Source code: https://cwa.run/next-auth Auth.js: https://authjs.dev/ Middleware config: https://dub.sh/Apr6dvD Resend: https://resend.com/ Node.js: https://nodejs.org/en ShadcnUI: https://ui.shadcn.com/ Clerk: https://dub.sh/SdVFxFU Learn how to add advanced authentication to your NextJS App. Key Features: - ๐ Next-auth v5 (Auth.js) - ๐ Next.js 14 with server actions - ๐ Credentials Provider - ๐ OAuth Provider (Social login with Google & GitHub) - ๐ Forgot password functionality - โ๏ธ Email verification - ๐ฑ Two factor verification (2FA) - ๐ฅ User roles (Admin & User) - ๐ Login component (Opens in redirect or modal) - ๐ Register component - ๐ค Forgot password component - โ Verification component - โ ๏ธ Error component - ๐ Login button - ๐ช Logout button - ๐ง Role Gate - ๐ Exploring next.js middleware - ๐ Extending & Exploring next-auth session - ๐ Exploring next-auth callbacks - ๐ค useCurrentUser hook - ๐ useRole hook - ๐ง currentUser utility - ๐ฎ currentRole utility - ๐ฅ๏ธ Example with server component - ๐ป Example with client component - ๐ Render content for admins using RoleGate component - ๐ก๏ธ Protect API Routes for admins only - ๐ Protect Server Actions for admins only - ๐ง Change email with new verification in Settings page - ๐ Change password with old password confirmation in Settings page - ๐ Enable/disable two-factor auth in Settings page - ๐ Change user role in Settings page (for development purposes only) Timestamps 00:00 Intro & Demo 02:05 Project setup 15:19 Routing crash course 38:06 Home page 48:40 Card wrapper 01:04:51 Login form 01:23:08 Register form 01:40:16 Database & Prisma setup 01:57:14 Create user 02:06:30 Middleware & Login 02:50:52 Callbacks 03:20:34 OAuth (Google & Github) 03:47:58 Resend (Sending emails) 04:19:27 Email verification 04:48:12 Reset password email 05:08:11 Reset password form 05:22:48 Two factor authentication 05:55:28 User button 06:15:02 Server & Client example 06:30:06 Admin example 06:47:25 Settings page 07:33:09 Sponsor demo 07:38:14 Deployment
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.