Turborepo makes monorepo builds 10x faster with intelligent caching and task orchestration. But most teams only use turbo run build and miss the powerful APIs underneath.
The Free APIs You're Missing
1. Remote Caching — Share Build Cache Across CI/Team
# Login to Vercel (free tier includes remote cache)
npx turbo login
npx turbo link
# Now builds are cached across ALL machines
turbo run build # First run: 45s
# On another machine or CI:
turbo run build # Cache hit: 0.2s
Your colleague builds the same code? Instant cache hit. CI runs the same tests? Already cached.
2. Task Dependencies — Topological Build Orchestration
// turbo.json
{
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"]
},
"test": {
"dependsOn": ["build"],
"inputs": ["src/**", "test/**"]
},
"lint": {},
"dev": {
"cache": false,
"persistent": true
}
}
}
^build means "build all dependencies first." Turbo figures out the correct order automatically.
3. Filtering — Run Tasks for Specific Packages
# Only build packages that changed since main
turbo run build --filter=...[main]
# Only build @myorg/ui and its dependents
turbo run build --filter=@myorg/ui...
# Build everything except docs
turbo run build --filter=!./apps/docs
# Only packages in apps/ directory
turbo run build --filter=./apps/*
4. Generators — Scaffold New Packages
turbo gen workspace
# Interactive: creates new package with correct config
# Or custom generators:
turbo gen run new-component
// turbo/generators/config.ts
import { PlopTypes } from "@turbo/gen";
export default function generator(plop: PlopTypes.NodePlopAPI) {
plop.setGenerator("new-component", {
description: "Create a new React component package",
prompts: [{ type: "input", name: "name", message: "Component name?" }],
actions: [
{ type: "addMany", destination: "packages/{{ name }}", templateFiles: "templates/**" },
],
});
}
5. Environment Variables — Per-Task Env Management
{
"tasks": {
"build": {
"env": ["API_URL", "NODE_ENV"],
"passThroughEnv": ["CI", "VERCEL"]
},
"test": {
"env": ["DATABASE_URL", "TEST_API_KEY"]
}
},
"globalEnv": ["GITHUB_TOKEN"],
"globalPassThroughEnv": ["HOME"]
}
Turbo invalidates cache when env vars change. No more stale builds from env mismatches.
Getting Started
npx create-turbo@latest
cd my-turborepo
turbo run build
Need data from any website delivered as clean JSON? I build production web scrapers that handle anti-bot, proxies, and rate limits. 77 scrapers running in production. Email me: Spinov001@gmail.com
Check out my awesome-web-scraping list for the best scraping tools and resources.
Top comments (0)