πŸ“ Tutorials

What is a Monorepo? A Simple Explanation for Developers


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

ToolWhat it does
pnpm workspacesPackage management for monorepos
npm workspacesSame, built into npm
TurborepoBuild system with caching (by Vercel)
NxFull monorepo framework with plugins
LernaOlder 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