Get started

To use the JavaScript SDK, import the JavaScript SDK package into your projects. In this documentation, we use Visual Studio Code as the editor and npm as the package manager.

Important

There is no longer a requirement to set up an npm feed. If you previously retrieved a package from the public feed, first clean up your configuration by running the command npm config delete @sitecore:registry or by removing the line that begins with @sitecore:registry from the npmrc file.

Install the package

To install the JavaScript SDK, run the following command:

RequestResponse
npm install @sitecore/sc-contenthub-webclient-sdk
Warning

You must configure the default npm registry, in addition to the Sitecore public feed, because the JavaScript SDK package depends on other npm packages from the default npm registry.

How you import the library depends on whether your project uses CommonJS or ECMAScript Modules (ESM).

If using CommonJS

Import the SDK with require:

RequestResponse
const sdk = require('@sitecore/sc-contenthub-webclient-sdk');

You must either remove "type": "module", or set it to "commonjs".

If using ESM

Import the SDK with import:

RequestResponse
import sdk from '@sitecore/sc-contenthub-webclient-sdk';

You must also set "type": "module" in your package.json.

Do you have some feedback for us?

If you have suggestions for improving this article,