Turborepo — High-Performance JS/TS Monorepo Build System
Incremental build system for JavaScript and TypeScript monorepos by Vercel. Remote caching, parallel execution, and zero-config setup. Never rebuild unchanged packages. 28,000+ stars.
What it is
Turborepo is an incremental build system for JavaScript and TypeScript monorepos, developed by Vercel. It understands the dependency graph between packages in your monorepo and only rebuilds what has changed. Combined with remote caching, it ensures that no build work is ever done twice across your entire team or CI.
Turborepo is designed for frontend and full-stack teams managing multiple packages, apps, and shared libraries in a single repository.
How it saves time or tokens
In a typical monorepo, running build or test across all packages is slow because every package rebuilds from scratch. Turborepo hashes inputs for each task and caches the outputs. When you run the same task with the same inputs, it replays the cached output instantly. Remote caching means your teammate or CI server can reuse the cache from your local build. Teams report build times dropping by 40-80% after adopting Turborepo.
How to use
- Create a new monorepo or add Turborepo to an existing one:
# New monorepo
npx create-turbo@latest my-monorepo
# Or add to existing project
npm install turbo --save-dev
- Configure tasks in
turbo.json:
{
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"test": {
"dependsOn": ["build"]
},
"lint": {}
}
}
- Run tasks across all packages:
npx turbo build
npx turbo test
npx turbo build test lint # parallel where possible
Example
A monorepo structure with Turborepo:
my-monorepo/
apps/
web/ # Next.js app
api/ # Express server
packages/
ui/ # Shared React components
config/ # Shared ESLint, TS configs
utils/ # Shared utilities
turbo.json
package.json
Running npx turbo build builds packages/utils first (no dependencies), then packages/ui (depends on utils), then apps/web and apps/api in parallel (both depend on ui). If packages/utils has not changed since the last build, its output is replayed from cache in milliseconds.
Related on TokRepo
- Automation tools — Explore build and CI automation tools
- Coding tools — Browse developer productivity tools
Common pitfalls
- Not specifying
outputsinturbo.json. Without output declarations, Turborepo cannot cache task results, and you lose the primary performance benefit. - Forgetting to set up remote caching for CI. Local caching helps individual developers, but remote caching is where the biggest gains come from in team environments. Link with
npx turbo login && npx turbo link. - Using
dependsOn: ["build"](without the^prefix) when you mean cross-package dependencies. The^prefix means 'run this task in dependencies first', while without it means 'run this task in the same package first'.
Frequently Asked Questions
Turborepo hashes the inputs for each task (source files, environment variables, dependencies). When a task runs, it uploads the output artifact to a remote cache (Vercel by default, or self-hosted). When any team member or CI runner runs the same task with the same inputs, Turborepo downloads and replays the cached output instead of rebuilding.
Yes. Turborepo works with npm, pnpm, and yarn workspaces. It reads the workspace configuration from your package manager and builds the dependency graph automatically. No additional configuration is needed.
Both are monorepo build tools with caching and task scheduling. Turborepo focuses on simplicity and zero-config for JS/TS projects. Nx provides more features like code generators, module boundaries, and support for non-JS languages. Turborepo is often chosen for smaller monorepos or teams that prefer minimal tooling.
Turborepo itself is open source and free. Remote caching via Vercel has a free tier (limited cache size) and paid plans for larger teams. You can also self-host the remote cache server to avoid vendor dependency.
Yes. Turborepo provides a prune command that generates a minimal subset of the monorepo for a specific app, making Docker builds faster by only including the packages that app depends on. This reduces Docker layer sizes and build times.
Citations (3)
- Turborepo GitHub— Turborepo is an incremental build system by Vercel
- Turborepo Documentation— Remote caching and task scheduling documentation
- Turborepo Docker Guide— Turborepo prune for Docker builds
Related on TokRepo
Source & Thanks
Discussion
Related Assets
Cucumber.js — BDD Testing with Plain Language Scenarios
Cucumber.js is a JavaScript implementation of Cucumber that runs automated tests written in Gherkin plain language.
WireMock — Flexible API Mocking for Java and Beyond
WireMock is an HTTP mock server for stubbing and verifying API calls in integration tests and development.
Google Benchmark — Microbenchmark Library for C++
Google Benchmark is a library for measuring and reporting the performance of C++ code with statistical rigor.