A modern, production-ready monorepo template built with pnpm workspaces, Turborepo, and a comprehensive set of development tools.
- Package Management: pnpm with workspaces
- Build System: Turborepo for task orchestration
- Versioning & Publishing: Changesets
- Build Tool: Vite
- Testing: Vitest
- Code Quality:
- ESLint - Linting
- Prettier - Code formatting
- Commitlint - Commit message linting
- lint-staged - Pre-commit hooks
- cspell - Spell checking
monorepo-starter/
├── apps/ # Applications
│ └── storybook/ # Component documentation and showcase
├── meta/ # Meta configuration
│ └── repo-config.ts # Repository configuration
├── packages/ # Shared packages
│ ├── ui/ # Core UI component library
│ ├── configs/ # Shared configuration packages
│ │ ├── eslint-config/
│ │ └── typescript-config/
│ ├── utils/ # Utility packages
│ └── vite-plugins/ # Vite plugin packages
├── scripts/ # Build and utility scripts
│ └── init-repo.ts # Repository initialization script
├── package.json # Root package.json
├── pnpm-workspace.yaml # pnpm workspace configuration
├── turbo.json # Turborepo configuration
└── tsconfig.json # Root TypeScript configuration
- Node.js >= 24.0.0
- pnpm >= 9.0.0
-
Clone the template repository
git clone <your-repo-url> cd monorepo-starter
-
Configure the repository
Edit
meta/repo-config.tsand update the following configuration:export const REPO_CONFIG: RepoConfig = { namespace: "@your-org", // Your organization namespace author: { name: "Your Name", email: "[email protected]" }, homepage: "https://your-website.com", repository: "https://github.com/your-org/your-repo.git", bugs: { url: "https://github.com/your-org/your-repo/issues" }, packageManager: "[email protected]", engines: { node: ">=24.0.0" } }
-
Plan your packages
Organize your packages in the
packages/directory according to your needs:packages/ui/- UI component librarypackages/configs/- Shared configuration packagespackages/utils/- Utility function packagespackages/vite-plugins/- Custom Vite plugins
Update
PACKAGES_CONFIGandAPPS_CONFIGinmeta/repo-config.tsto match your package structure. -
Install dependencies
pnpm install
This will automatically:
- Ensure only pnpm is used (via
only-allow) - Run the repository initialization script to update all package.json files
- Ensure only pnpm is used (via
-
Start development
pnpm dev
The first thing you need to do after getting the template is to modify the configuration in meta/repo-config.ts:
REPO_CONFIG: Update namespace, author, homepage, repository URL, and other repository-level settingsPACKAGES_CONFIG: Define your package structure and metadataAPPS_CONFIG: Configure your applications (like Storybook)
Organize your packages in the packages/ directory:
- UI Components: Place your component library in
packages/ui/ - Configurations: Shared configs (ESLint, TypeScript, etc.) in
packages/configs/ - Utilities: Reusable utility functions in
packages/utils/ - Plugins: Custom Vite plugins in
packages/vite-plugins/
Run pnpm install to:
- Install all dependencies
- Automatically initialize the repository (updates all package.json files based on your configuration)
pnpm install- Install dependencies and initialize repositorypnpm build- Build all packages and appspnpm dev- Start development servers for all appspnpm lint- Lint all packagespnpm lint:fix- Lint and auto-fix issues in all packagespnpm format- Format code with Prettierpnpm check-types- Type-check all packagespnpm spellcheck- Check spelling in codepnpm spellcheck:fix- Fix spelling issues in codepnpm test- Run tests across all packagespnpm clean- Clean build artifacts
Each package can have its own scripts defined in its package.json. Common scripts include:
dev- Start development modebuild- Build the packagetest- Run testslint- Lint the package
This template uses Vitest for testing. Write your tests alongside your code:
// Example: packages/ui/src/components/button/__tests__/button.test.ts
import { describe, it, expect } from "vitest"
describe("Button", () => {
it("should render correctly", () => {
// Your test here
})
})This template uses Changesets for version management and publishing:
- Create a changeset:
pnpm changeset - Version packages:
pnpm changeset version - Publish packages:
pnpm changeset publish
- Create a new package: Add it to
PACKAGES_CONFIGinmeta/repo-config.tsand create the directory structure - Add dependencies: Use
pnpm add <package>in the specific package directory - Run tasks: Use Turborepo to run tasks across packages:
pnpm turbo <task> - Format code: Run
pnpm formatbefore committing - Commit changes: Follow conventional commits (enforced by Commitlint)
- ESLint: Configured for consistent code quality
- Prettier: Automatic code formatting
- Commitlint: Enforces conventional commit messages
- lint-staged: Runs linters on staged files before commit
- Create a feature branch
- Make your changes
- Ensure all tests pass and code is linted
- Commit using conventional commit format
- Create a pull request
[Add your license here]