• Repo
  • Docs
  • Getting Started
  • Add to Existing Project

Add Turborepo to your existing project

Turborepo can be used in any project to speed up the execution of scripts in your package.json.

After you install turbo, you'll be able to run all your package.json tasks from turbo instead of your package manager.

By configuring your turbo.json correctly, you'll notice how caching helps your tasks run a lot faster.

Quickstart

  1. If you don't have one already, create a new application:
npx create-next-app@latest
  1. Install turbo:
npm install turbo --save-dev
  1. Add a turbo.json file at the base of your new repository:

For more information on configuring your turbo.json, see the Configuration Options documentation.

turbo.json
{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "outputs": [".next/**"]
    },
    "lint": {
      "outputs": []
    }
  }
}
  1. Edit .gitignore

Add .turbo to your .gitignore file. The CLI uses these folders for logs and certain task outputs.

+ .turbo
  1. Try running build and lint with turbo:
npx turbo build lint

This runs build and lint at the same time.

  1. Without making any changes to the code, try running build and lint again:
npx turbo build lint

You should see terminal output like this:

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    185ms >>> FULL TURBO

Congratulations - you just completed a build and lint in under 200ms.

To learn how this is possible, check out our core concepts docs.

  1. Try running dev with turbo:
npx turbo dev

You'll notice that your dev script starts up. You can use turbo to run any script in your package.json.

Last updated on 2022-11-21T15:44:11.000Z