Introducing Bit’s NPM Package Registry

Jonathan Saring
Bits and Pieces
Published in
3 min readJan 31, 2018

--

Both public and private components and modules shared with Bit are now made instantly available to install with NPM and Yarn.

Instantly make any part of your project available with NPM

This means components and modules shared with Bit can be installed by any developer without having to install Bit at all.

You can now make any part of your project available to install via NPM and Yarn in just a few seconds (yes) without having to set up any new repos, boilerplate packages or change your project’s source code.

To share components and modules to Bit’s free NPM registry all you have to do is install Bit, choose components from any project and share them with Bit. They will automatically be made available via NPM and Yarn.

To consume components and modules all you have to do is configure Bit as a Scoped registry for your native NPM or Yarn client, and install components just like any other package. You don’t have to install Bit at all.

Here are the main advantages for using Bit as your package registry:

  • You can share code directly from your project without having to change it, or having to set up any additional repositories and packages.
  • You can easily search and discover your components and view useful information such as test results, auto-parsed docs and more.
  • You can install components using NPM and Yarn.
  • You can easily update components by import their source code into any project with Bit, editing it in the project itself, and update changes.
  • It’s 100% for open source, and for up to 3 private Scopes.

Example

Here is an example React app that contains reusable React components.

Once Bit was added to this project (which took seconds), its component are shared and made individually available to install as packages from this collection.

Here is an example for the React Hero component from this project.

As you can see, it was shared directly from the project itself (which wasn’t changed).

To install this component as a package all you have to do is to configure bitsrc.io as a Scoped registry for your local NPM client.

npm config set @bit:registry https://node.bitsrc.io

Or, if using Yarn:

yarn config set "@bit:registry" "https://node.bitsrc.io/"

Then, you can simply copy-paste the relevant command from the component’s page into your CLI to install it in your project.

Artifactory

If working with a privately hosted Node.js registry such as the JFrog Artifactory, you can also configure bitsrc as a virtual NPM registry which will allow Artifactory to proxy the bistrc.io registry and cache the components.

Ecosystem compatibility and seamless usage

Installing components with package managers like NPM and Yarn is another step in Bit’s eco-system compatibility. This makes the adoption of Bit within a team or organization seamless, as developers won’t even have to install Bit to use the shared components and modules.

Open source library maintainers can easily provide their users with a way to discover and install individual components from their library, without having to work hard, make source code changes or restructure the library.

Feel free to get started for yourself and try it out.

--

--

I write code and words · Component-driven Software · Micro Frontends · Design Systems · Pizza 🍕 Building open source @ bit.dev