A production-minded authentication boilerplate built with Next.js, Auth.js (NextAuth), Prisma ORM, and PostgreSQL.
- Next.js 14 application architecture
- Auth.js (NextAuth) credentials-based authentication
- Prisma ORM with PostgreSQL
- Type-safe database access through Prisma Client
- Protected dashboard route with authentication middleware
- Secure password validation using bcrypt
- JWT session strategy with optional "remember me" behavior
Modern web applications need authentication flows that are secure, scalable, and easy to extend. A common challenge is implementing user authentication while keeping the codebase maintainable, protecting private routes, and preparing the system for role-based access control as the application grows.
This project addresses that challenge by providing a focused authentication foundation with database-backed users, encrypted password checks, session handling, and route protection.
This project is a boilerplate/system focused on security best practices and type-safe database interactions.
It uses Auth.js (NextAuth) with a credentials provider for login, Prisma ORM for strongly typed database operations, and PostgreSQL as the persistence layer. Protected routes are handled through NextAuth middleware, making the project a practical starting point for applications that need private dashboards, session persistence, and future role-based authorization rules.
- Next.js 14
- React
- TypeScript
- Auth.js / NextAuth
- Prisma ORM
- PostgreSQL
- bcrypt
- Zod
- React Hook Form
- Tailwind CSS
- shadcn/ui components
- Node.js installed
- PostgreSQL database available
- npm installed
Clone the repository and install the dependencies:
npm installCreate a .env file in the project root and configure the required environment variables:
PRISMA_DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
AUTH_SECRET="your-auth-secret"Generate the Prisma Client:
npx prisma generateApply the database schema:
npx prisma migrate devStart the development server:
npm run devOpen the application at:
http://localhost:3000
npm run build
npm run start