@voicebip/web — Browser SDK
@voicebip/web — Browser SDK
The @voicebip/web package handles WebRTC signaling, mic access, SSE transcript streaming, and call lifecycle so you don’t have to. The package is not yet published to npm — this page previews the planned API.
Installation (Coming Soon)
No build-time native dependencies. ESM-only; requires a bundler (Vite, webpack, esbuild, Next.js, etc.) or a browser that supports ES modules natively.
In the Meantime
Use the Browser Calls (WebRTC) guide to wire WebRTC directly — the guide includes a complete minimal JavaScript example that works today without any SDK dependency.
Prerequisites
You need a scoped token — a short-lived JWT that authorises one call to one agent. Mint it server-side via @voicebip/sdk and pass it to the browser through your own API route.
See Browser Calls (WebRTC) for the full server + browser walkthrough.
Quick start
API Reference
new VoicebipCall(opts)
call.start(): Promise<void>
Requests mic access, creates the WebRTC peer connection, POSTs the SDP offer to /v1/webrtc/offer, applies the answer, and opens the transcript SSE stream.
- Resolves once
connectionState === 'connected'. - Rejects (and emits
error) on any setup failure. - Throws
Errorif called from any state other thanidle.
call.hangup(): Promise<void>
Closes the peer connection, stops all mic tracks, and closes the SSE stream. Idempotent — safe to call multiple times.
call.setMuted(muted: boolean): void
Enables or disables the local microphone track. The remote peer hears silence; no signaling event is sent.
call.state: CallState
Read-only. One of 'idle' | 'connecting' | 'connected' | 'ended' | 'error'.
call.on(event, handler): () => void
Registers an event handler. Returns an unsubscribe function.
Events
TranscriptEvent
Types
State machine
call.on('ended', ms) fires exactly once regardless of how the call ends (remote hang-up, network drop, hangup(), or an error in start()).
Security
- The SDK refuses to operate without a scoped token. Passing a
pk_live_*workspace key is rejected at the API gateway with401 UNAUTHENTICATED. - The token authorises one
POST /v1/webrtc/offerfor one agent. A mismatch betweenagentIdand the token’swebrtc_agent_idclaim returns403 PERMISSION_DENIED. - Tokens expire in ≤10 minutes. Mint a fresh token for each call session — do not cache them.
- TURN relay endpoints are embedded in the
ice_serversresponse — pass them through to the SDK unchanged.
What this SDK does not do
- No UI. No call buttons, no transcript widget, no audio visualisations. Build your own using the events above.
- No React-specific helpers. A
useVoicebipCall()hook will ship in@voicebip/web-react. - No call control beyond mute + hangup. Hold, transfer, and DTMF are server-side operations — use
@voicebip/sdkfor those. - No IE or Safari < 14. WebRTC + EventSource required.