SDKsWeb SDK

Overview

Embed a real-time audio and video Omniagent in the browser

The Web SDK embeds an Omniagent directly in your web application: a real-time agent your users can see, hear, and talk to. It ships a ready-made widget with the avatar and its controls, which you drop into any page, and a typed API for driving the session from your own code.

Start it with init. The agent can connect as soon as you call it, or wait behind a launcher button until the visitor clicks it. Set an accent color to match your brand. On multi-page sites, persistence keeps one session alive as the visitor moves between pages.

The SDK doesn't depend on any framework, so it works with React, Vue, Angular, or plain JavaScript. It ships with TypeScript definitions. The standalone build has no dependencies; the ESM build needs @reduxjs/toolkit 2.x installed alongside it.

The package is published to npm as @touchcastllc/napster-companion-api. These pages cover version 2. Upgrading from 1.x? See Upgrading to Web SDK 2.0.

New to the Napster API? The Quickstart walks the whole path end to end — create an Omniagent, mint a connection token on your backend, and embed it with this SDK — in a few minutes.

In this section

Supported environments

Browsers

Chrome and Edge 105+, Safari 16+, Firefox 121+

Bundlers

Any bundler that supports ES2020 and package exports: Vite, webpack 5, Rollup, esbuild, Angular CLI

Plain HTML

No build tools required, with the standalone build

The page must be served over HTTPS, or from localhost during development, because the SDK needs microphone access.

How it fits together

The Web SDK is the browser client for the WebRTC channel. A typical integration has three parts:

  1. Your backend has an endpoint that creates a session and returns its connection token. See Add a token endpoint, and Authentication for the API key.
  2. Your frontend calls init with a function that fetches a token from that endpoint.
  3. The SDK mounts the widget and gives you an instance right away, or a controller if you use the launcher button. It then asks for the microphone, calls your function for a token, opens the WebRTC connection, and renders the avatar. Wait for onAvatarReady before you send commands.

The token expires within seconds and works for a single session, which is why the SDK fetches it itself, right before connecting. Always create it on your server. Never ship your API key to the browser.

Next steps

On this page