DEV Community

Alex Spinov
Alex Spinov

Posted on

Turborepo Has a Free API: Monorepo Builds That Actually Scale

Your monorepo CI takes 45 minutes because it rebuilds everything. Turborepo makes it take 45 seconds.

What Is Turborepo?

Turborepo is a build system for JavaScript/TypeScript monorepos. It understands your dependency graph, caches everything, and only rebuilds what changed.

npx create-turbo@latest
Enter fullscreen mode Exit fullscreen mode

The Pipeline

// turbo.json
{
  "$schema": "https://turbo.build/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**"]
    },
    "test": {
      "dependsOn": ["build"]
    },
    "lint": {},
    "dev": {
      "persistent": true,
      "cache": false
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

"dependsOn": ["^build"] means: build my dependencies first, then build me. Turborepo figures out the order and runs independent tasks in parallel.

Why It's Fast

1. Caching — Every task output is cached by inputs hash. Same inputs → cached result → instant.

turbo run build
# First run: 2 minutes
# Second run: 100ms (cached)
Enter fullscreen mode Exit fullscreen mode

2. Remote caching — Share cache across your entire team and CI:

npx turbo login
npx turbo link
# Now CI uses cached results from your teammates' builds
Enter fullscreen mode Exit fullscreen mode

3. Parallel execution — Independent packages build simultaneously.

4. Pruned subsets — Deploy only what changed:

turbo prune --scope=@myapp/web --docker
# Generates minimal package.json + lockfile for just the web app
Enter fullscreen mode Exit fullscreen mode

Real Impact

A team with 15 packages in their monorepo:

  • Before Turborepo: CI builds took 38 minutes
  • After: 4 minutes (first run), 30 seconds (cached)
  • Remote cache hit rate: 85%

Building monorepo infrastructure? Check out my developer tools or email spinov001@gmail.com.

Top comments (0)