My fav place to learn to code is Scrimba
Get 20% off a subscription with my link 👇
https://scrimba.com/learn-nextjs-c02m...
Want to add secure email and password authentication with email verification to your Next.js or React app? In this tutorial, I walk you through how to set up Better Auth, a powerful authentication library that makes secure user authentication simple and flexible.
🚀 What You’ll Learn:
How to install and configure Better Auth
Set up email & password sign-up/login
Send and verify email addresses
Protect routes with middleware
Best practices for authentication flows
🔧 Tech Stack:
Next.js / React
TypeScript
Better Auth
Resend (or your preferred email provider)
✅ Whether you're building a SaaS, dashboard, or any modern web app, this auth setup gives you a solid, production-ready foundation.
🔗 Resources:
Better Auth - https://www.better-auth.com/
GitHub Repo - https://github.com/bwestwood11/better...
Neon & Drizzle Docs - https://orm.drizzle.team/docs/tutoria...
Resend - https://resend.com/
Time Stamps
0:00 Intro
0:07 What We Will Make
1:23 Create Next.js Project
2:46 Install the Better Auth Package
3:22 Set the Environment Variables
4:16 Start the initial build of Better Auth Instance
4:57 Configure Neon Database with Drizzle ORM
9:53 Better Auth CLI for Creating Schema
12:48 Enable the Email and Password Authentication
13:20 Create a Catch All Route for Better Auth
14:29 Create a Better Auth Client Instance
15:49 Next.js Specific Set Up Steps - Cookies & Middleware
19:40 Sign Up Users with Server Side Method
28:53 Briefly Explaining How Cookies work on Sign Up
30:42 Create the Email Verification Process on Sign Up
41:27 Sign In User with Server Side Method
46:23 Sign Up and Sign In with Client Method
51:25 Handling Errors
52:55 Logout Functionality
55:23 Outro