DEV Community

Alex Spinov
Alex Spinov

Posted on

Turborepo Has a Free API — Here's How to Use It for High-Performance Monorepos

Turborepo is a high-performance build system for JavaScript and TypeScript monorepos. It provides remote caching, parallel execution, and intelligent task scheduling — all for free.

Getting Started

npx create-turbo@latest my-monorepo
cd my-monorepo
Enter fullscreen mode Exit fullscreen mode

turbo.json Configuration

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

Running Tasks

# Build all packages in dependency order
turbo build

# Run only changed packages
turbo build --filter=...[HEAD~1]

# Run specific package and its dependencies
turbo build --filter=web...

# Parallel lint and test
turbo lint test
Enter fullscreen mode Exit fullscreen mode

Remote Caching

# Login to Vercel for remote caching
npx turbo login
npx turbo link

# Now builds are cached across your team
turbo build  # First run: builds everything
turbo build  # Second run: instant cache hit
Enter fullscreen mode Exit fullscreen mode

Workspace Dependencies

// apps/web/package.json
{
  "dependencies": {
    "@repo/ui": "workspace:*",
    "@repo/config": "workspace:*"
  }
}
Enter fullscreen mode Exit fullscreen mode

Turborepo automatically understands the dependency graph and builds packages in the correct order.

Task Graph Visualization

turbo build --graph=graph.svg
Enter fullscreen mode Exit fullscreen mode

This generates a visual graph of your task dependencies — invaluable for debugging build order issues.


Need to extract or automate web content at scale? Check out my web scraping tools on Apify — no coding required. Or email me at spinov001@gmail.com for custom solutions.

Top comments (0)