SDKsWeb SDK

Installation

Add the Web SDK to your project with the ESM or standalone build

The Web SDK ships in two build types. Use the ESM build for any project with a bundler; use the standalone build to drop the SDK into a plain HTML page with a single script tag.

Choose a build

ESM buildStandalone build
Installnpm install<script> tag
Best forReact, Vue, Angular, any bundlerPlain HTML, no build step
Dependencies@reduxjs/toolkit peer dependencyAll bundled
Tree-shakingYesNo
Entry pointNapsterCompanionApiSdk importwindow.napsterCompanionApiSDK

ESM build

Install the SDK and its peer dependency:

npm install @touchcastllc/napster-companion-api @reduxjs/toolkit

@reduxjs/toolkit is a required peer dependency. Import the SDK and its stylesheet in your application:

import { NapsterCompanionApiSdk } from "@touchcastllc/napster-companion-api";
import "@touchcastllc/napster-companion-api/styles";

The stylesheet can also be loaded via a <link> tag or CSS @import if you prefer not to import it in JavaScript:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@touchcastllc/napster-companion-api@latest/lib/index.css" />

Standalone build

Add a single script tag to your HTML. All dependencies are bundled — no build tools required.

<script src="https://cdn.jsdelivr.net/npm/@touchcastllc/napster-companion-api@latest/lib/index.standalone.js"></script>

The SDK attaches itself to window.napsterCompanionApiSDK. The stylesheet is included in the standalone bundle, so no separate CSS import is needed.

Get a token

Before you can initialize the SDK you need a connection token. Tokens are short-lived and minted on your server — never expose your API key in the browser.

Next steps

On this page