A production-ready authentication template built with Next.js 16, Better Auth, Prisma, and Neon DB. This project provides a clean and scalable foundation for implementing authentication in modern web applications.
- ✅ Email & Password Authentication
- ✅ GitHub OAuth Login
- ✅ Better Auth integration (secure + modern auth handling)
- ✅ Prisma ORM for database management
- ✅ Neon DB (serverless Postgres)
- ✅ Clean and modular folder structure
- ✅ Ready for extension (Google auth, roles, sessions, etc.)
| Technology | Purpose |
|---|---|
| Next.js 16 | Full-stack React framework |
| Better Auth | Authentication system |
| Prisma | ORM for database access |
| Neon DB | Serverless PostgreSQL database |
| TypeScript | Type safety |
git clone https://github.com/AliAbdullah0/Template-Better-Auth-Email-Password
cd your-repo-namenpm installCreate a .env file in the root directory and add:
DATABASE_URL=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
BETTER_AUTH_SECRET=
NEXT_PUBLIC_APP_URL=http://localhost:3000npx prisma generatenpx prisma migrate devnpx prisma studionpm run devApp will be available at: 👉 http://localhost:3000
- User signs up with email + password
- Credentials stored securely via Prisma
- Login validates credentials
- User clicks "Login with GitHub"
- Redirect to GitHub OAuth
- Callback handled by Better Auth
- User session created
├── app/
| ├── start/ # Show current logged in users info
│ ├── api/ # Auth routes
│ ├── (auth)/ # Login / Signup pages
├── lib/
| ├── auth-client.ts
| ├── utils.ts
│ ├── auth.ts # Better Auth config
│ └── prisma.ts # Prisma client
├── prisma/
│ └── schema.prisma
├── components/
- Passwords are hashed before storage
- Environment variables are required for secrets
- OAuth handled securely via Better Auth
I will soon extend this project with:
- 🔹 Google / Discord OAuth
- 🔹 Role-based access control (RBAC)
- 🔹 Email verification
- 🔹 Password reset flow
- 🔹 Multi-factor authentication (MFA)
- Add Google Auth
- Add email verification
- Add password reset
- Add user roles
Contributions are welcome! Feel free to fork the repo and submit a PR.
MIT License
If you found this helpful, give it a ⭐ on GitHub!