A production-ready Next.js 15 web application with comprehensive authentication, theming, internationalization, and modern development tools. Built with TypeScript and designed for rapid project bootstrapping using a unified single-domain architecture.
- Better-auth integration with Next.js 15 server actions
- Simplified single-domain authentication - no CORS complexity
- Layout-based route protection for optimal performance
- Session management with TanStack Query optimization
- Social OAuth providers (GitHub, Google) support
- 8 pre-built color themes
- Dynamic theme switching with CSS custom properties
- 5 radius presets (0 to 1.0rem) for component customization
- Dark/light mode support with
next-themes - Persistent user preferences with localStorage
- English and French translations out of the box
- Context-based settings store for language switching
- Comprehensive translation coverage for all UI components
- Easy extension for additional languages
- Server-Sent Events (SSE) for real-time updates
- Database-persisted notifications with Prisma
- Mark as read/unread functionality with optimistic updates
- Bulk operations (mark all as read)
- TanStack Query integration for efficient state management
- next-pwa integration with Workbox caching strategies
- Comprehensive service worker with runtime caching
- App manifest with customizable icons and metadata
- Offline-first approach for improved user experience
- Single Next.js app serving both frontend and API routes
- Turborepo for optimized build orchestration
- pnpm workspaces with workspace protocol
- Shared packages for types, configs, and utilities
- No CORS issues - same origin for all requests
- Simplified deployment - one Vercel project instead of two
- Automated project setup script for instant bootstrapping
- TanStack Query for server state management
- Radix UI primitives for accessible components
- Tailwind CSS with shadcn/ui component system
- Prisma ORM with PostgreSQL database
- ESLint and TypeScript strict configuration
- Debug page at
/debugfor troubleshooting - Hot reload and fast refresh in development
-
Clone and setup:
git clone <your-repo-url> my-new-project cd my-new-project npx tsx scripts/setup-project.ts
-
Install dependencies:
pnpm install
-
Start development:
make dev
-
Open your browser:
- Web App: http://localhost:3000
- API Health: http://localhost:3000/api/health
The project uses PostgreSQL with Docker Compose for local development:
# Start database
make db-up
# Stop database
make db-down
# View database logs
make db-logs
# Reset database (β οΈ deletes all data)
make db-migrate-reset# Run migrations
make db-migrate
# Open Prisma Studio (database GUI)
make db-studio
# Generate Prisma client
pnpm --filter @boilerplate/web db:generateIf you encounter database authentication errors like:
Authentication failed against database server, the provided database credentials for `user` are not valid.
This issue has been fixed in the template! The problem was that the Makefile was using hardcoded database credentials instead of reading from the environment variables created by the setup script.
Solution:
- Run the setup script:
npx tsx scripts/setup-project.ts - The script will automatically:
- Create proper
.env.projectandapps/web/.env.localfiles - Update the Makefile to use environment variables instead of hardcoded values
- Configure the correct database credentials
- Create proper
For new projects:
- Always run
npx tsx scripts/setup-project.tsafter cloning - The setup script ensures all database credentials are properly configured
- The Makefile now reads from
.env.projectinstead of using hardcoded values
Manual fix (if needed):
# Reset database with correct credentials
make db-clean
make db-upIf you see "Port 3000 is in use", the app will automatically use the next available port (3001, 3002, etc.).
The project uses two environment files:
.env.project- Docker Compose configuration (database credentials)apps/web/.env.local- Next.js application configuration
Both are automatically generated by the setup script and should not be manually edited.
boilerplate/
βββ apps/
β βββ web/ # Next.js 15 unified web application
β βββ app/
β β βββ (web)/ # Public pages (landing page)
β β βββ (auth)/ # Authentication pages
β β βββ (protected)/ # Protected dashboard pages
β β βββ api/ # API routes
β β βββ components/ # UI components
β β βββ lib/ # Utilities and libraries
β βββ prisma/ # Database schema and migrations
β βββ public/ # Static assets
βββ packages/
β βββ config/ # Shared configurations
β βββ types/ # Shared TypeScript types
βββ package.json # Root workspace configuration
βββ turbo.json # Turborepo configuration
- Next.js 15 with App Router and React 19 (frontend + API)
- TanStack Query for server state management
- Tailwind CSS with shadcn/ui components
- Radix UI primitives for accessibility
- next-themes for theme management
- next-pwa for Progressive Web App features
- Better-auth for authentication
- Prisma ORM with PostgreSQL
- Server-Sent Events for real-time features
@boilerplate/config- ESLint, Tailwind, TypeScript, and project configs@boilerplate/types- Shared TypeScript interfaces and types
- No CORS configuration required - everything runs on the same origin
- Simplified authentication - cookies work seamlessly
- Better performance - no cross-origin request overhead
- Easier deployment - single Vercel project
- Cost effective - one project billing
- Layout-based protection eliminates per-page auth checks
- Simplified cookie configuration for single domain
- Session optimization with TanStack Query caching
- Automatic redirects with middleware-based routing
- 8 color themes with semantic color tokens
- Dynamic CSS custom properties for runtime theme switching
- Radius customization with 5 preset values
- Persistent user preferences across sessions
- Real-time updates via Server-Sent Events
- Database persistence with Prisma models
- Optimistic UI updates for instant feedback
- Bulk operations for improved user experience
- Turborepo caching for faster builds
- Parallel task execution across workspaces
- Shared configuration to reduce duplication
- Type-safe APIs with end-to-end TypeScript
pnpm dev # Start web application development server
pnpm build # Build all applications and packages
pnpm lint # Lint all code
pnpm type-check # TypeScript type checking
pnpm test # Run all tests
pnpm clean # Clean build outputs
pnpm format # Format code with Prettierpnpm --filter @boilerplate/web dev # Web app only
pnpm --filter @boilerplate/web build # Build web appmake db-up # Start PostgreSQL with Docker
make db-down # Stop PostgreSQL container
make db-migrate # Run database migrations
make db-studio # Open Prisma Studio
make db-reset # Reset database (development only)make dev # Start web app (alias for pnpm dev)
make logs # View database container logs
make clean # Clean all build outputs and cachesThe project supports automatic multi-environment deployment:
- Production (
mainbranch): Auto-deploy to production domain - Staging (
stagingbranch): Auto-deploy to staging subdomain - Development (feature branches): Auto-deploy to preview URLs
Required in Vercel (set once, works for all environments):
DATABASE_URL=postgresql://user:password@host:5432/database
BETTER_AUTH_SECRET=your-32-character-secret-key-hereOptional (for social OAuth):
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secretAutomatic Variables (provided by Vercel):
VERCEL_ENV- Environment type (production/preview/development)VERCEL_GIT_COMMIT_REF- Git branch nameVERCEL_URL- Deployment URLNODE_ENV- Node environment
-
Create Vercel Project
- Import your repository
- Set Root Directory to
apps/web - Framework preset: Next.js (auto-detected)
-
Configure Environment Variables
- Add
DATABASE_URLandBETTER_AUTH_SECRETin Vercel dashboard - Variables work across all environments automatically
- Add
-
Database Setup (Recommended: Neon)
- Create PostgreSQL database at neon.tech
- Neon automatically creates branch databases for staging/preview
- Use the same
DATABASE_URLfor all environments
-
Deploy
- Push to
mainfor production - Push to
stagingfor staging environment - Push to any branch for preview deployments
- Push to
See docs/vercel-deployment.md for complete deployment guide.
- Enhanced security headers configured in vercel.json
- Environment variable validation
- Secure cookie configuration for production
- CSRF protection with Better-auth
- No CORS vulnerabilities with single domain architecture
This boilerplate includes a comprehensive setup script that automates project configuration:
npx tsx scripts/setup-project.tsWhat it configures:
- Project Branding: Names, descriptions, and metadata
- Database Configuration: PostgreSQL credentials and connection strings
- Environment Files: Generates
.envfiles with secure secrets - Package Namespaces: Updates all package.json files
- Docker Setup: Configures container names and networking
- PWA Manifest: Updates app metadata for Progressive Web App features
- Documentation: Updates deployment guides with your project details
- Create theme file in
apps/web/app/lib/theme/ - Export theme colors following the existing pattern
- Update
getAvailableThemes()in project config - Theme appears automatically in settings panel
- Create translation files in
apps/web/app/locales/ - Update i18n configuration in
apps/web/app/lib/i18n.ts - Update
getSupportedLocales()in project config
- Add new routes in
apps/web/app/api/ - Update Prisma schema for database changes
- Generate types in
@boilerplate/types - Use TanStack Query for client-side data fetching
Visit /debug in any environment for comprehensive diagnostics:
- Environment detection status
- Authentication and session information
- Cookie inspection with copy functionality
- API health checks
- Configuration verification (non-sensitive)
- Common issues and solutions
- Authentication problems: Check
/debugfor session and cookie status - Environment detection: Verify VERCEL_ENV and branch name in debug page
- Database issues: Check API health at
/api/health - Build failures: Ensure all environment variables are set
- Deployment Guide:
docs/vercel-deployment.md - Project Instructions:
CLAUDE.md(for AI assistants) - Migration Guide:
MIGRATION_GUIDE.md(historical reference)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Update documentation
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js team for the excellent framework
- Vercel for deployment platform and automatic environment detection
- Better-auth for simplified authentication solution
- Radix UI for accessible component primitives
- shadcn/ui for beautiful component designs
- Neon for PostgreSQL with database branching
Ready to build something amazing? π
Start with npx tsx scripts/setup-project.ts to customize this boilerplate, then make dev to begin development!