A production-grade Next.js template engineered with enterprise-level best practices, comprehensive testing infrastructure, and strict code quality standards. Built for teams that demand excellence in maintainability, scalability, and developer experience. This template is based in the practices used in ZeroChats.
This template embodies professional software engineering principles with a focus on:
- SOLID Principles - Applied rigorously across all code
- Design Pattern Driven - Appropriate patterns for maintainability and scalability
- Documentation First - Comprehensive TSDoc/JSDoc for all functions, classes, and hooks
- Testing as Priority - Unit, integration, and E2E tests with meaningful coverage
- Code Quality - Strict linting, formatting, and file size limits (200 lines max)
- Type Safety - Full TypeScript strict mode enforcement
See AGENTS.md for complete development guidelines and principles that are used to guide AI Agents.
- Next.js 15.5.4 - React framework with App Router
- React 19.1.0 - Latest React with Server Components
- TypeScript 5.x - Strict type safety
- TailwindCSS 4.x - Utility-first CSS framework
- Prisma 6.7.0 - Type-safe database ORM
- Vitest - Fast unit and integration testing
- Playwright - Reliable E2E testing across browsers
- Comprehensive test setup - Separate unit, integration, and E2E test suites
- Docker-based test database - Isolated test environment
- ESLint - Next.js and TypeScript linting rules
- Prettier - Consistent code formatting
- Pre-commit hooks - Automated testing and formatting before commits
- Strict TypeScript - Maximum type safety configuration
- PostgreSQL - Production-ready relational database
- Docker Compose - Containerized development and test databases
- Prisma migrations - Version-controlled database schema
- Environment management - Secure configuration with
.envfiles
- Node.js 20.x or higher
- npm 10.x or higher
- Docker and Docker Compose (for database)
- Git for version control
# Clone the repository
git clone https://github.com/alexfdez1010/next-template.git my-project
cd my-project
# Install dependencies
npm install# Copy environment template
cp .env.example .env
# Edit .env with your configuration
# DATABASE_URL="postgresql://postgres:postgres@localhost:5432/db"# Start PostgreSQL container
npm run database
# Run migrations (in another terminal)
npm run database:dev
# Stop database when done
npm run database:down# Start development server with Turbopack
npm run devOpen http://localhost:3000 to see your application.
npm run dev- Start development server with databasenpm run build- Build production bundlenpm run start- Start production servernpm run launch- Build and start with database
npm run lint- Run ESLint and Prisma formattingnpm run format- Format code with Prettiernpm run lint-format- Lint and format (required before commits)npm run pre-commit- Run tests and code quality checks
npm test- Run all tests (unit, integration, E2E)npm run test:unit- Run unit tests onlynpm run test:integration- Run integration tests onlynpm run test:e2e- Run E2E tests with Playwrightnpm run playwright- Open Playwright UI for debugging
npm run database- Start PostgreSQL containernpm run database:down- Stop database containernpm run database:dev- Run migrations in developmentnpm run database:deploy- Deploy migrations to productionnpm run database:studio- Open Prisma Studionpm run database:test- Start test database
next-template/
βββ src/
β βββ app/ # Next.js App Router pages
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
β βββ globals.css # Global styles
βββ prisma/
β βββ schema.prisma # Database schema
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ e2e/ # End-to-end tests
β βββ setup.ts # Test configuration
βββ public/ # Static assets
βββ generated/ # Generated Prisma client
βββ .vscode/ # VS Code settings
βββ compose.yml # Development database
βββ compose-test.yml # Test database (ephemeral)
βββ eslint.config.mjs # ESLint configuration
βββ playwright.config.ts # Playwright configuration
βββ vitest.config.ts # Vitest configuration
βββ tsconfig.json # TypeScript configuration
βββ tailwind.config.ts # TailwindCSS configuration
βββ .prettierrc # Prettier configuration
βββ .env.example # Environment template
βββ AGENTS.md # AI Agents Development guidelines
Located in tests/unit/, these test individual functions and components in isolation.
npm run test:unitLocated in tests/integration/, these test module interactions and API endpoints.
npm run test:integrationLocated in tests/e2e/, these test complete user flows across browsers.
npm run test:e2e# Create a new migration
npm run database:dev
# Deploy migrations to production
npm run database:deploy
# Check migration status
npm run database:check
# Open Prisma Studio
npm run database:studio- Edit
prisma/schema.prisma - Run
npm run database:devto create migration - Test with
npm run database:test - Commit schema and migration files
Ensure all required environment variables are set:
DATABASE_URL="postgresql://user:password@host:5432/database"# Build production bundle
npm run build
# Run production server
npm run starttsconfig.json- TypeScript strict mode, path aliaseseslint.config.mjs- Next.js and TypeScript rules.prettierrc- Single quotes, trailing commas, 2-space tabsvitest.config.ts- Node environment, 10s timeoutplaywright.config.ts- Multi-browser E2E testing
- Next.js Documentation
- React Documentation
- TypeScript Handbook
- TailwindCSS Documentation
- Prisma Documentation
- Vitest Documentation
- Playwright Documentation
This is a template repository. To use it:
- Click "Use this template" on GitHub
- Clone your new repository
- Remove or modify this README as needed
- Start building your application