Packages and code re-use

In this article...

We’ll introduce you to packages and show you how they make it easy to share and reuse code across experiences and consume any of the hundreds of thousands of open-source NPM projects.

What is a package?

Packages are like code building blocks. You can publish a package that solves a particular problem and then reuse it again and again across multiple experiences.

At its most basic, a package is a folder with a package.json file in it. It must have a name, and a version, and to be useful it should point to a file containing some javascript code.

Features

Qubit has built-in support for packages, meaning that you can:

  • Share and reuse packages across experiences
  • Publish packages to your own private organizational scope
  • Access private packages designed specifically by Qubit to help with building experiences
  • Access thousands of open source modules made available through npm

What packages are available?

There are three types of package made available through this feature:

  • Private packages maintained by Qubit
  • Private packages published to your own scope
  • Public packages

Private packages maintained by Qubit

We have a growing number of private packages, designed specifically for make building experiences easier.

These are prefixed with the Qubit scope, e.g. @qubit/poller.

TIP: Each package has a readme file that explains its purpose and how you might use it, with practical examples. To access the file, select the documentation link: package docs.

Private packages published to your own scope

You can also access a special private scope that you can publish your own packages to. Once done, you can reuse packages across all of your organization's properties.

See Using a private package scope.

Public packages available through npm and maintained by the JavaScript community

We also integrate with npm, which hosts hundreds of thousands of useful open source packages that you can use.

WARNING: Your use of the npm Registry is governed by the terms and licenses defined by npm Inc. These public packages are not tested or validated by Qubit and that we therefore cannot accept any liability or obligation in relation to their use.

Last updated: June 2020
Did you find this article useful?