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.
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:
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:
You must either remove "type": "module", or set it to "commonjs".
If using ESM
Import the SDK with import:
You must also set "type": "module" in your package.json.