Production-ready Next.js 15 boilerplate with zero external account dependencies
A comprehensive, self-contained Next.js monorepo template for building SaaS applications. No Clerk, no Resend, no PostHog, no Sentry — just pure Next.js with best practices.
✅ Authentication
- NextAuth.js with credentials + OAuth (GitHub, Google)
- Email verification workflow
- Password reset flow
- JWT session strategy
- Protected routes & middleware
✅ Database
- Prisma ORM with PostgreSQL
- User, Account, Session, Subscription models
- Type-safe database access
- Docker Compose for local PostgreSQL
- React Email templates (welcome, verification, password reset)
- Nodemailer with SMTP
- Mailpit for local development (http://localhost:8025)
- Production-ready for any SMTP provider
✅ UI
- Shadcn UI components
- Tailwind CSS
- Dark mode support
- Responsive design
- Lucide icons
✅ Payments (Optional)
- Stripe integration (opt-in)
- Subscription management
- Webhook handling
✅ Monorepo
- Turborepo for fast builds
apps/web(Next.js 15),apps/docs(VitePress)- Shared packages: database, email, payments (Stripe opt-in), TypeScript config, ESLint config
- pnpm workspaces
Zero external account dependencies: This is a custom boilerplate, not next-forge. Auth is NextAuth.js (no Clerk), email is Nodemailer (no Resend), database is Prisma + Docker PostgreSQL (no Neon). No PostHog, Sentry, or BetterStack. Run pnpm install, docker compose up -d, and start coding — no SaaS signups required.
- Node.js 18+ and pnpm
- Docker Desktop (for PostgreSQL + Mailpit)
# Create project from template
gh repo create my-app --template faizkhairi/next-boilerplate --private --clone
cd my-app
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env
# Generate NEXTAUTH_SECRET
openssl rand -base64 32
# Add the output to .env as NEXTAUTH_SECRET
# Start Docker services (PostgreSQL + Mailpit)
docker compose up -d
# Push database schema
pnpm db:push
# Start development server
pnpm devOpen http://localhost:3000 in your browser.
View development emails at http://localhost:8025 (Mailpit UI).
next-boilerplate/
├── apps/
│ └── web/ # Next.js 15 application
│ ├── app/
│ │ ├── (auth)/ # Auth routes
│ │ ├── api/ # API routes
│ │ └── dashboard/ # Protected routes
│ ├── components/ # React components
│ │ └── ui/ # Shadcn components
│ └── lib/ # Utilities & config
│
├── packages/
│ ├── database/ # Prisma schema + client
│ ├── email/ # React Email templates + Nodemailer
│ └── typescript-config/ # Shared TypeScript configs
│
├── docker-compose.yml # PostgreSQL + Mailpit
├── turbo.json # Turborepo config
└── .env.example # Environment variables template
See .env.example for all available variables. Key settings:
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | postgresql://postgres:postgres@localhost:5432/next_boilerplate |
NEXTAUTH_URL |
App URL | http://localhost:3000 |
NEXTAUTH_SECRET |
NextAuth.js secret (32+ chars) | Required |
SMTP_HOST |
SMTP server host | localhost (Mailpit) |
SMTP_PORT |
SMTP server port | 1025 (Mailpit) |
SMTP_FROM |
Email sender address | [email protected] |
Uncomment and fill in .env to enable:
- GitHub OAuth:
GITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET,NEXT_PUBLIC_GITHUB_ENABLED - Google OAuth:
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,NEXT_PUBLIC_GOOGLE_ENABLED
Uncomment and fill in .env to enable payments:
STRIPE_SECRET_KEYSTRIPE_WEBHOOK_SECRETNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
# Start all services (PostgreSQL + Mailpit)
docker compose up -d
# Start Next.js dev server
pnpm dev
# Or run both database and dev server
pnpm db:push && pnpm dev# Push schema changes to database (development)
pnpm db:push
# Create a migration (production)
pnpm db:migrate
# Open Prisma Studio (database GUI)
pnpm db:studioAll emails sent in development are caught by Mailpit:
- SMTP Server: localhost:1025
- Web UI: http://localhost:8025
In production, set SMTP_* in .env to any SMTP provider (e.g. Gmail, Mailgun, SendGrid). No external account required for the boilerplate itself.
-
Registration →
/auth/register- User fills form (name, email, password)
- Account created with
emailVerified: null - Verification email sent with 24-hour token
-
Email Verification →
/auth/verify?token=xxx&email=xxx- User clicks link from email
- Token validated,
emailVerifiedupdated - Welcome email sent
-
Login →
/auth/login- Email + password (or OAuth)
- Email verification check (prevents unverified login)
- JWT session created, redirect to
/dashboard
-
Password Reset →
/auth/forgot-password+/auth/reset-password- User requests reset (email sent with 1-hour token)
- Clicks link, sets new password
- Token deleted, password updated
# Install Netlify CLI
npm install -g netlify-cli
# Deploy
netlify deploy --buildEnvironment Variables: Add all .env variables in Netlify dashboard.
Database: Use Docker PostgreSQL (same as local), or a managed PostgreSQL (e.g. Neon, Supabase) if you prefer.
# Build for production
pnpm build
# Start production server
pnpm startDatabase: PostgreSQL on the same VPS (Docker or native install).
| Layer | Technology | Version |
|---|---|---|
| Framework | Next.js | ^15.1.6 |
| Language | TypeScript | ^5.7.3 |
| Auth | NextAuth.js | ^4.24.11 |
| Database | Prisma + PostgreSQL | ^6.19.2 |
| Nodemailer + React Email | Latest | |
| UI | Shadcn + Tailwind CSS | Latest |
| Forms | React Hook Form + Zod | Latest |
| Payments | Stripe (opt-in) | Latest |
| Monorepo | Turborepo + pnpm | Latest |
| Command | Description |
|---|---|
pnpm dev |
Start Next.js dev server |
pnpm build |
Build for production |
pnpm start |
Start production server |
pnpm lint |
Run ESLint |
pnpm db:push |
Push Prisma schema to database |
pnpm db:migrate |
Create database migration |
pnpm db:studio |
Open Prisma Studio |
-
Environment Variables: Set all required env vars in production environment
DATABASE_URL— PostgreSQL connection stringNEXTAUTH_SECRET— Generate withopenssl rand -base64 32NEXTAUTH_URL— Your production URL (e.g., https://app.example.com)SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASS— SMTP provider credentialsGITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET— If using GitHub OAuthGOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET— If using Google OAuthSTRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET— If using Stripe payments
-
Database: Run migrations on production database
pnpm db:migrate deploy
-
Build: Verify production build succeeds
pnpm build
-
Tests: Run full test suite
pnpm test -
Security:
- Enable HTTPS (SSL/TLS certificate)
- Set secure cookies (NEXTAUTH_URL must be https://)
- Configure CORS if needed
- Review rate limiting settings in
lib/ratelimit.ts - Audit dependencies for vulnerabilities:
pnpm audit
-
Email: Configure production SMTP provider
- Recommended: Resend, Mailgun, SendGrid, or Gmail SMTP
- Update
FROM_EMAILin email service
-
OAuth (if enabled):
- Add production callback URLs to GitHub/Google OAuth apps
- Update redirect URIs to match production domain
-
Stripe (if enabled):
- Switch to live API keys
- Configure webhook endpoint in Stripe Dashboard
- Test subscription flow end-to-end
-
Health Check: Verify
/api/healthendpoint returns 200 -
Smoke Tests:
- User registration works
- Email verification works
- Login works
- Password reset works
- OAuth login works (if enabled)
- Protected routes require auth
- Stripe checkout works (if enabled)
-
Monitoring:
- Set up uptime monitoring (e.g., UptimeRobot, Better Uptime)
- Monitor error logs
- Monitor database performance
- Set up alerts for 5xx errors
-
Performance:
- Verify page load times < 3s
- Check Lighthouse scores
- Enable Next.js caching strategies
- Configure CDN for static assets (if not using Vercel/Netlify)
Vercel (Recommended)
pnpm build && vercel --prod- Auto-configures Next.js optimizations
- Add PostgreSQL via Vercel Postgres or external provider
- Add environment variables in Vercel Dashboard
Netlify
pnpm build && netlify deploy --prod- Use @netlify/plugin-nextjs
- Add PostgreSQL via external provider (Supabase, Neon, etc.)
- Add environment variables in Netlify Dashboard
Self-Hosted (Docker)
docker build -t next-boilerplate .
docker run -p 3000:3000 --env-file .env.production next-boilerplate- Requires PostgreSQL accessible from container
- Use docker-compose.yml for full stack deployment
This is a boilerplate template. Fork it and customize for your needs!
MIT
- Documentation: See CLAUDE.md for AI-assisted development guide
- Issues: GitHub Issues
Faiz Khairi — faizkhairi.github.io — @faizkhairi