English

Turborepo makes monorepo development fast with intelligent task scheduling and caching.

Setup

npx create-turbo@latest

Project Structure

my-turborepo/
├── apps/
│   ├── web/
│   └── docs/
├── packages/
│   ├── ui/
│   └── config/
├── turbo.json
└── package.json

Configuration

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**"]
    },
    "lint": {},
    "dev": {
      "cache": false,
      "persistent": true
    }
  }
}

Running Tasks

# Run build for all packages
turbo build

# Run dev for specific app
turbo dev --filter=web

# Run lint in parallel
turbo lint

Remote Caching

# Login to Vercel for remote caching
turbo login

# Link to remote cache
turbo link

Shared Packages

// packages/ui/src/Button.tsx
export function Button({ children, onClick }) {
  return (
    <button onClick={onClick} className="btn">
      {children}
    </button>
  );
}
// apps/web/src/page.tsx
import { Button } from '@repo/ui';

export default function Page() {
  return <Button onClick={() => alert('Hi!')}>Click me</Button>;
}

Benefits

  1. Intelligent caching - Never rebuild unchanged code
  2. Parallel execution - Run tasks concurrently
  3. Remote caching - Share cache across team
  4. Incremental builds - Only rebuild what changed
  5. Task orchestration - Respects dependencies
0
0
0
0