Bit supports CommonJS API for consuming components as packages.
To install components with npm or yarn we first need to configure
@bit as a scope registry. Bit does it by default as part of the
bit login process.
Configuring Bit as a scoped registry for NPM and Yarn
Bit does this step automatically after a successful
To configure scoped registry we use the
npm config command.
npm config set '@bit:registry' https://node.bit.dev
To install private components use npm login. Use your Bit credentials to login.
npm login --registry=https://node.bit.dev [email protected]
To learn more about NPM scoped registries, please refer to NPM's documentation.
Package naming convention
Package naming convention includes the Bit owner, Collection name and the component ID (including namespaces).
yarn add <owner>.<collection>.<component-ID>
Using a packaged component
After installing the component as a package, import/require it in the following format:
import component from '@bit.<owner>.<collection>.<component-ID>';