Components once exported to a remote scope can be consumed in any other project/app with the package manager of your choice.
npm install @my-org/scope.my-component yarn add @my-org/scope.my-component
You may also use Bit to install components:
bit install @my-org/scope.my-component
Once installing the component, the component resides in the node_modules directory.
To use the component in the code, import the code as follow:
import { myComponent } from '@my-org/scope.my-component';
When using bit.cloud for hosting components, consumers will need to configure their package manager to know where to fetch components from. Do this by configuring .npmrc file:
- First of all - install Bit on your system.
- Run the following command:
bit login
- Bit generated a
.npmrcin your user-home directory (~in macOS/Linux,%USERPROFILE%in Windows) with a basic config containing your authentication token. - Open the
.npmrcfile and add the following line (complete the account name according to where components are hosted)
@ACCOUNT:registry=https://node.bit.cloud
An example configured .npmrc file looks something like this:
@teambit:registry=https://node.bit.cloud //node.bit.cloud/:_authToken=<TOKEN>
When self hosting Bit on your own server you need to publish the components as packages to any package registry. The authentication process for the package manager is very much the same other then the fact you can't use bit login to set your token.