See a live example of a repository with Turborepo and Bit.
To use Bit in an existing Turborepo, open a terminal at the root of the workspace and run:
bit init
You will be prompted to answer a few questions:
- Which environment you will like to use? pick the most relevant default stack (you can add more later).
- Would you like to use your own package manager? Yes.
- Would you like to use MCP server for AI-powered development? Yes.
- Which IDE to set up? Select from list (you can add more later).
The output should be the following:
đ§ Setting up MCP server for vscode... â MCP server configured for vscode successfully initialized a bit workspace. âšī¸ Additional Information: đ Components will be created in: bit-components/{scope}/{name} đ For CI/CD setup, visit: https://bit.dev/docs/getting-started/collaborate/exporting-components#custom-ci/cd-setup đ¯ Environment: bitdev.react/react-env đ¤ MCP server configured for: vscode đĻ External package manager mode enabled đĄ Run pnpm install (or yarn install/npm install) to install dependencies
You have successfully added Bit support to your Turborepo workspace!
See the two generated file; workspace.jsonc, which includes all Bit related configuration, and .bitmap which tracks the Bit components in the workspace. Make sure to add and commit these files to your repository.
Now that you have Bit in your Turborepo monorepo, you can run any Bit commands to manage components:
bit templates // see all available templates you can use bit create // create a new component bit list // list all components in the workspace
All components are linked to the local node_modules. To use a Bit component in a Turborepo package, use the module link:
import { anotherBitComponent } from '@my-org/my-scope/another-bit-component';
To ensure the compiled outputs of components is up-to-date in node_modules, you need to run one of the following processes:
bit watch // runs component-compilation in a watch mode, ensure compiled node-modules for components are up-to-date bit start // runs bit-devserver which also ensures compiled node-modules for components are up-to-date
To import a local Turborepo package by a Bit component you need to ensure the Turborepo package is also published to a registry, so when other consumers install the Bit component, they will get the Turborepo package as a dependency.
To create a new app, simply choose the *-app template when creating a new component:
bit create react-app apps/my-react-app
Now you can use the following application-workflow commands:
bit app list // lists all available Bit apps in the repotisory bit run <name> // runs a Bit app in a seperate dev-server, alongside your app
See the docs here about adding the relevant CI script package.