A practical Next.js foundation for teams that want a clean engineering baseline before application complexity starts growing.
Built with a focus on sensible defaults for code quality, application structure, resilience, testing, and continuous integration.
- Next.js with App Router
- TypeScript
- Tailwind CSS
- ESLint
- Prettier with Tailwind class sorting
- Husky Git hooks
- lint-staged
- Conventional Commit validation
- Centralized site configuration
- Metadata baseline
- Environment configuration pattern
- Shared
Containercomponent cn()utility withclsxandtailwind-merge- Loading state
- Error boundary
- Custom 404 page
- Basic security headers
- Reduced framework fingerprint with
poweredByHeader: false - Optimized font loading with
next/font - Vitest
- React Testing Library
- GitHub Actions CI
The project follows a modular, scalable directory pattern designed to enforce separation of concerns:
βββ AGENTS.md
βββ CLAUDE.md
βββ CONTRIBUTING.md
βββ LICENSE
βββ README.md
βββ SECURITY.md
βββ commitlint.config.ts
βββ eslint.config.mjs
βββ next-env.d.ts
βββ next.config.ts
βββ package-lock.json
βββ package.json
βββ postcss.config.mjs
βββ prettier.config.mjs
βββ public
β βββ file.svg
β βββ globe.svg
β βββ next.svg
β βββ vercel.svg
β βββ window.svg
βββ src
β βββ app
β β βββ error.tsx
β β βββ favicon.ico
β β βββ global-error.tsx
β β βββ globals.css
β β βββ layout.tsx
β β βββ loading.tsx
β β βββ not-found.tsx
β β βββ page.tsx
β βββ components
β β βββ layout
β β β βββ container.test.tsx
β β β βββ container.tsx
β β βββ ui
β β βββ button.test.tsx
β β βββ button.tsx
β βββ config
β β βββ site.ts
β βββ lib
β βββ utils.ts
βββ tsconfig.json
βββ tsconfig.tsbuildinfo
βββ vitest.config.mjs
βββ vitest.setup.ts
- Framework: Next.js 15+ (App Router)
- Language: TypeScript (Strict Mode)
- Styling: Tailwind CSS
- Unit/Component Testing: Vitest & React Testing Library
- Automation Pipeline: GitHub Actions CI
- Code Quality: ESLint, Prettier
Ensure you have Node.js 20+ installed on your system.
-
Clone the repository:
git clone https://github.com/allydevs-engineering/nextjs-production-starter.git cd nextjs-production-starter -
Install project dependencies:
npm ci
-
Configure environment variables: Duplicate the example configuration file and update the values:
cp .env.example .env.local
-
Launch the development server:
npm run dev
Open http://localhost:3000 in your browser to see the live template.
Execute these scripts from the root directory using your terminal:
| Script | Purpose |
|---|---|
npm run dev |
Spins up the local development server with hot-reloading. |
npm run build |
Compiles an optimized, production-ready build output. |
npm run start |
Starts the Next.js production server after building. |
npm run lint |
Inspects your codebase for structural type, stylistic, and standard ESLint errors. |
npm run format:check |
Verifies your files conform to Prettier styling guides. |
npm run format:fix |
Automatically formats your code based on Prettier guidelines. |
npm run test |
Launches the Vitest execution block runner in interactive watch mode. |
npm run test:run |
Single execution run of the full test suite (ideal for automated environments). |
The repository includes a local Git workflow designed to catch basic issues before code is committed.
Staged files run through:
ESLint
β
Prettier
Component tests use:
- Vitest
- React Testing Library
- jsdom
This project leverages Vitest and JSDOM to perform ultra-fast component testing without the overhead of heavy browser engines.
- File Naming Pattern: Always locate tests alongside their source files using the format
*.test.tsxor*.test.ts. - Global Mocking: Next.js specific components like
useRouter,usePathname, and routing layers are automatically mocked globally withinvitest.setup.ts.
To verify components locally before submitting changes, run:
npm run test:runGitHub Actions runs the project quality checks on repository pushes and pull requests. Every push or Pull Request targeting main, master, or develop triggers an automated GitHub Actions pipeline (.github/workflows/ci.yml).
The pipeline verifies:
Format check
β
Lint
β
Tests
β
Production build
The pipeline runs sequentially through the following gates:
- Dependency Analysis: Validates lockfile integrity via clean installation rules (
npm ci). - Quality Verification: Assesses code formatting (
prettier), strict code style rules (next lint), and strict type architecture checks (tsc). - Test Safety Execution: Executes the complete Vitest component validation matrix.
- Production Readiness Build: Compiles a real-world server production deployment asset to catch hidden bundling failures.
To keep our commit history clear, legible, and easy to parse, follow the standardized Conventional Commits naming convention:
feat:Introduces a brand new feature or module to the codebase.fix:Patches a bug or addresses a runtime malfunction.docs:Modifying or adding text within Markdown or documentation files.style:Formatting code, fixing lint styles, or adjusting missing semicolons (no operational logic code changes).refactor:Changes to structural code that neither fixes a bug nor adds a feature.test:Appending missing unit tests or adjusting testing code.chore:Maintenance updates, dependency version alignment bumps, or tooling adjustments (next.config.js,tsconfig.json).
Examples:
feat: add authentication flow
fix: handle invalid configuration
docs: update setup instructions
test: add container tests
chore: update dependencies
Production problems are easier to prevent when basic engineering practices are established early.
This starter provides a small, understandable foundation rather than a large boilerplate containing features every project may not need.
The goal is not to solve every application concern.
The goal is to start with:
- a clear project structure
- consistent code formatting
- commit validation
- basic application boundaries
- automated testing
- continuous integration
From there, teams can add the architecture and capabilities their specific application requires.
This starter keeps performance-specific implementation minimal because the correct strategy depends on the application.
When adding assets and integrations:
- Use
next/fontfor optimized font loading. - Prefer
next/imagefor application images. - Use
next/scriptto control third-party script loading. - Measure production builds with Lighthouse and real-world monitoring before optimizing.
The starter provides the baseline. Application-specific performance decisions should follow actual requirements and measurements.
This repository does not include:
- Authentication
- Database or ORM
- State management library
- API implementation
- Docker
- E2E testing
- Analytics
- A component library
- Application-specific business logic
These choices depend on the requirements of the application being built.
Contributions, improvements and discussions are welcome. Before opening a pull request:
- Run formatting checks.
- Run linting.
- Run the test suite.
- Ensure the production build succeeds.
- Use a Conventional Commit message.
See CONTRIBUTING.md for development and contribution guidelines.
Please review SECURITY.md for information about reporting security vulnerabilities.
AllyDevs Engineering
Engineering capability for digital agencies.
Website: https://allydevs.com
This project is licensed under the MIT License. See LICENSE.