Embedding with the Web SDK
The Web SDK handles video rendering, audio, and session lifecycle. It works with React, Vue, Angular, and vanilla JavaScript.
1. Install the SDK
npm install @touchcastllc/napster-companion-api @reduxjs/toolkit
2. Get a session token (server-side)
Call POST /public/connections with your companion ID. The response includes a token — pass this securely to the client.
3. Initialize in React
Import NapsterCompanionApiSdk, create a container ref, and call NapsterCompanionApiSdk.init(token, { mountContainer: containerRef.current, position: "bottom-right" }) inside a useEffect. Call instance.destroy() on cleanup.
Tip: Examples for Vue, Angular, and vanilla JS are in the WebRTC docs. Always generate the session token on your backend — never in client-side code.