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
Installation
Add the SDK to your project — ESM or standalone build.
Initialization
Start the SDK, connect right away or on a click, and tear it down.
Configuration
The full config object: layout, style, features, and callbacks.
Features
Every built-in feature, from inactivity timeout to screen sharing.
Persistence
Keep one session alive across page navigation.
Events
Lifecycle callbacks and the incoming data your client receives.
Messaging
Send messages and commands to the agent from your code.
Methods
The instance API and the top-level SDK object.
Examples
Integration examples for React, Vue 3, Angular, and vanilla JS.
Troubleshooting
Common issues, debug mode, and performance notes.
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:
- 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.
- Your frontend calls
initwith a function that fetches a token from that endpoint. - 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
onAvatarReadybefore 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.