A monorepo is a single Git repository that contains multiple projects. Instead of having separate repos for your frontend, backend, and shared libraries, everything lives in one place.
Google, Meta, Microsoft, and Uber all use monorepos. But that doesnβt mean you should β it depends on your situation.
Monorepo vs. multi-repo
Multi-repo (one repo per project):
github.com/company/web-app β React frontend
github.com/company/api-server β Node.js backend
github.com/company/shared-utils β Shared library
github.com/company/mobile-app β React Native app
Monorepo (one repo, multiple projects):
github.com/company/platform
βββ apps/
β βββ web/ β React frontend
β βββ api/ β Node.js backend
β βββ mobile/ β React Native app
βββ packages/
β βββ shared/ β Shared utilities
β βββ ui/ β Component library
β βββ config/ β Shared ESLint/TS config
βββ package.json
Why use a monorepo?
Shared code is easy. Change a shared component, and every app that uses it gets the update immediately. No publishing packages, no version mismatches.
Atomic changes. Need to update the API and the frontend at the same time? One PR, one review, one merge. In multi-repo, thatβs two PRs that need to be coordinated.
Consistent tooling. One ESLint config, one TypeScript config, one CI pipeline. Every project follows the same standards.
Easier refactoring. Rename a function in the shared library and update all consumers in the same commit.
Why NOT use a monorepo?
Complexity. You need specialized tools (Turborepo, Nx, pnpm workspaces). Simple npm install doesnβt cut it.
CI gets slow. Changing one file triggers builds for everything unless you set up smart caching.
Access control. Everyone can see everything. If teams need isolated repos, monorepos make that harder.
Git gets slow. Very large monorepos (millions of files) can make Git sluggish.
Tools
| Tool | What it does |
|---|---|
| pnpm workspaces | Package management for monorepos |
| npm workspaces | Same, built into npm |
| Turborepo | Build system with caching (by Vercel) |
| Nx | Full monorepo framework with plugins |
| Lerna | Older tool, now maintained by Nx |
Quick setup with pnpm
# pnpm-workspace.yaml
packages:
- 'apps/*'
- 'packages/*'
// Root package.json
{
"private": true,
"scripts": {
"dev": "turbo dev",
"build": "turbo build",
"test": "turbo test"
}
}
See: pnpm cheat sheet for workspace commands.
When to use a monorepo
Yes if:
- You have 2+ apps sharing code (frontend + backend, web + mobile)
- You want consistent tooling across projects
- Your team is small-to-medium and works across projects
- Youβre building a component library used by multiple apps
No if:
- You have one app
- Teams are completely independent and donβt share code
- You donβt want to learn monorepo tooling
- Your projects use completely different tech stacks