A development strategy where multiple projects are stored in a single repository to share code and simplify dependency management.
A monorepo (monolithic repository) stores multiple projects or services in a single Git repository, rather than splitting them across many separate repositories. All related code lives together in one place.
Think of it like an office building where all departments work under one roof versus separate buildings scattered across the city.
my-monorepo/
├── apps/
│ ├── web/ # Main website
│ ├── mobile/ # Mobile app
│ └── admin/ # Admin dashboard
├── packages/
│ ├── ui/ # Shared UI components
│ ├── utils/ # Shared utilities
│ └── api-client/ # API client library
Multiple projects, one repository. They share code easily while staying organized.
Code Sharing: Create a button component once, use it in web, mobile, and admin apps. Update it once, all apps get the improvement.
Atomic Changes: Update the API and all clients that use it in a single commit. No worrying about version mismatches.
Simplified Dependencies: One package.json, one set of dependencies, no version conflicts between projects.
Better Collaboration: Developers see all related code. Understanding how pieces fit together is easier.
No related topics found.
Google: Uses a massive monorepo containing billions of lines of code. Thousands of engineers work in it simultaneously.
Facebook: React, React Native, and related tools live in one monorepo.
Microsoft: VS Code extensions and core code in one repo.
Vercel: Next.js and its ecosystem packages are monorepo-based.
Nx: Powerful build system with caching, perfect for large monorepos.
Turborepo: Optimized for speed, handles builds and caching efficiently.
Yarn Workspaces / npm Workspaces: Built into package managers, good for simpler setups.
Lerna: Older tool, still used but less popular now.
Single Source of Truth: All code in one place. No hunting across repositories.
Easier Refactoring: Change a shared function, see all usages immediately.
Consistent Tooling: One ESLint config, one TypeScript config, one CI/CD setup.
Faster Onboarding: New developers clone one repo and see the entire system.
Repository Size: Can become large. Git operations may slow down (though modern tools handle this well).
Build Complexity: Building everything is wasteful. Need smart tools to build only what changed.
Access Control: Everyone sees everything. Sensitive projects might need separate repos.
Good For:
Not Ideal For:
Start with a tool like Turborepo or Nx. They handle the complexity, letting you focus on building. Most modern frameworks (Next.js, React, Angular) have monorepo examples and templates.
Monorepos are not right for everyone, but for projects with shared code and multiple applications, they dramatically improve developer experience and code quality.