nextjs-better-auth-template
v1.0.4
Published
Scaffold a Next.js auth template by marrrkkk
Readme
Next.js Better Auth Template
Install: npx nextjs-better-auth-template
A starter template for implementing authentication in Next.js using Better Auth. This template is designed as a practical foundation for developers building secure authentication systems, featuring built-in support for email verification, OAuth integration, and password management. Ideal for jumpstarting production-ready apps or learning modern auth workflows in Next.js.

Features
- ✉️ Email verification
- 🔄 Password reset functionality
- 📧 Email-based authentication
- 🔑 OAuth authentication (Google, GitHub)
Tech Stack
- Framework: Next.js 15
- UI Components: ShadCN
- Styling: Tailwind CSS
- Database: Neon (PostgreSQL)
- ORM: Drizzle
- Authentication: Better-auth
- Email: Nodemailer
Getting Started
Prerequisites
- Node.js (Latest LTS version recommended)
- npm or yarn
- PostgreSQL database (or Neon account)
Setting up Google App Password for Nodemailer
- Go to your Google Account settings (https://myaccount.google.com/)
- Enable 2-Step Verification if not already enabled
- Go to Security → App passwords (https://myaccount.google.com/apppasswords)
- Enter a name for your app (e.g., "Next.js Auth")
- Copy the password and use it as your
EMAIL_PASSin the.envfile
Installation
- Install with npx:
npx nextjs-better-auth-template- Install dependencies:
npm install- Set up environment variables by renaming
.env.exampleto.envor.env.localand fill in variables:
BETTER_AUTH_SECRET=
BETTER_AUTH_URL=http://localhost:3000 #Base URL of your app
DATABASE_URL=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
EMAIL_FROM=
EMAIL_USER=
EMAIL_PASS=
EMAIL_VERIFICATION_CALLBACK_URL=http://localhost:3000/email-verified- Run database migrations:
npx drizzle-kit generate
npx drizzle-kit migrate- Start the development server:
npm run devOpen http://localhost:3000 with your browser
Learn More
To learn more about the technologies used in this project:
