A complete TypeScript monorepo template with Next.js, React (Vite), Nest.js, and shared packages. Includes Docker configurations, ESLint, TypeScript configs, and Turborepo setup.
# Clone the repository
git clone https://github.com/yevgeniusr/ts-monorepo-boilerplate.git your-project-name
cd your-project-name
# Remove the existing remote
git remote remove origin
# Add your own remote repository
git remote add origin https://github.com/your-username/your-repo-name.git
# (Optional) Push to your new remote
git push -u origin main# Install dependencies
pnpm install
# Start all apps in development mode
pnpm dev
# Build all packages
pnpm build
# Run linting
pnpm lint
# Run tests
pnpm testts-monorepo-boilerplate/
βββ apps/
β βββ nextjs-app/ # Next.js 14 application
β βββ react-app/ # React + Vite application
βββ services/
β βββ nestjs-service/ # Nest.js backend service
βββ packages/
β βββ shared-package/ # Shared TypeScript package
β βββ eslint-config/ # Shared ESLint configurations
β βββ typescript-config/ # Shared TypeScript configurations
βββ configs/ # Configuration templates
β βββ eslint/
β βββ typescript/
β βββ prettier/
βββ docker/ # Dockerfiles for deployment
βββ package.json # Root package configuration
βββ turbo.json # Turborepo pipeline config
βββ pnpm-workspace.yaml # PNPM workspace config
- Next.js App - Next.js 14 with TypeScript, Tailwind CSS, ESLint, and Vitest
- React App - Vite-based React app with TypeScript, Tailwind CSS, ESLint, and Vitest
- Nest.js Service - Complete Nest.js backend with TypeScript, Jest, and ESLint
- Shared Packages - Reusable TypeScript packages for shared code
- Docker Support - Dockerfiles for backend, Next.js, and Vite apps
- Code Quality - ESLint, Prettier, and TypeScript configurations
- Build System - Turborepo for optimized builds and caching
| Command | Description |
|---|---|
pnpm dev |
Start all apps/services in development mode |
pnpm build |
Build all packages and apps |
pnpm lint |
Lint all code |
pnpm test |
Run all tests |
pnpm type:check |
Type check all TypeScript code |
pnpm format |
Format all code with Prettier |
pnpm clean |
Clean all build artifacts |
Each app/service has its own scripts in their package.json:
dev- Development modebuild- Production buildlint- Lint codetest- Run teststype:check- Type check
Before using this boilerplate, replace these placeholders throughout the codebase:
-
ts-monorepo-boilerplateβ Your project name- Used in: package names, workspace references, app titles
-
@ts-monorepo-boilerplate/*β Your package scope- Used in: all package.json files, import statements
- Example:
@ts-monorepo-boilerplate/shared-packageβ@my-project/shared-package
-
TypeScript Monorepo Boilerplateβ Your project description- Used in: package.json descriptions
-
yevgeniusrβ Your name/username- Used in: package.json author field
Use your IDE's find-and-replace (case-sensitive) to replace:
ts-monorepo-boilerplateβyour-project-name@ts-monorepo-boilerplateβ@your-scopeTypeScript Monorepo BoilerplateβYour Project DescriptionyevgeniusrβYour Name
- Copy an existing app folder (e.g.,
apps/nextjs-app/) - Rename it to your app name
- Update
package.jsonwith your app name - Update import paths in
tsconfig.jsonif needed
- Copy
services/nestjs-service/toservices/your-service-name/ - Update
package.jsonwith your service name - Update Dockerfile if using (in
docker/folder)
- Copy
packages/shared-package/topackages/your-package-name/ - Update
package.jsonwith your package name - Update imports in apps/services that use this package
Dockerfiles are available in the docker/ folder:
Dockerfile.backend- For Nest.js servicesDockerfile.web- For Next.js applicationsDockerfile.frontend- For Vite/React applications
Update the Dockerfiles with your actual service/app names before use.
ESLint configurations are provided for:
- Next.js apps - Uses Vercel's style guide
- Services - Node.js backend configuration
- Libraries - Shared package configuration
All configs extend from @ts-monorepo-boilerplate/eslint-config.
TypeScript configurations are provided for:
- Base - Common settings for all projects
- Next.js - Next.js-specific settings
- Service - Backend service settings
- Library - Shared package settings
The turbo.json includes pipelines for:
build- Builds all packages/apps/serviceslint- Lints all codetest- Runs teststype:check- Type checks TypeScriptdev- Development mode (no caching)clean- Cleans build artifacts
If you see TypeScript errors about missing types:
- Ensure
@ts-monorepo-boilerplate/typescript-configis installed - Check that
tsconfig.jsonextends the correct config - Run
pnpm installto ensure all dependencies are linked
If ESLint can't find configs:
- Ensure
@ts-monorepo-boilerplate/eslint-configis installed - Check that
.eslintrc.cjsextends the correct config - Verify the eslint-config package exports the right files
If builds fail:
- Check that all workspace dependencies are installed
- Verify
pnpm-workspace.yamlincludes all package paths - Ensure
turbo.jsonpipeline is correctly configured
- Always update placeholders - Replace all boilerplate names with your project names
- Keep configs in sync - When updating shared configs, ensure all apps/services use them
- Use workspace protocol - Always use
workspace:*for internal package dependencies - Test after setup - Run
pnpm installandpnpm buildto verify everything works
After setting up your monorepo:
- β Replace all placeholder names and keywords
- β Add your application code to the respective app/service folders
- β
Configure environment variables (
.envfiles) - β Set up CI/CD pipelines
- β Configure deployment (Docker, Vercel, etc.)
- β Add additional packages/services as needed
MIT License - see LICENSE file for details
- Package Manager: pnpm 10.10.0
- Build System: Turborepo 1.13.3
- Language: TypeScript 5.4
- Frontend: Next.js 14, React, Vite
- Backend: Nest.js
- Styling: Tailwind CSS
- Testing: Vitest, Jest
- Linting: ESLint, Prettier
- Docker: Node 22 base images
Note: This is a working boilerplate. You can use it as-is for testing, but remember to customize it for your project by replacing all placeholder values.