Skip to content

Client SDK overview

The Univerx Client SDK (@univerx/client-sdk) lets you embed real-time video calling and cobrowsing directly into your web application. When a visitor clicks a help button, they join a support queue, get connected to an available agent, and can share their screen — all without leaving your site.

  • You want to add live video support to your own website or web app.
  • You need cobrowsing: agents see and interact with the visitor’s browser in real time.
  • Your team manages queues and agents in the Univerx dashboard, and you want the customer-facing widget on your domain.
  • You are building a custom UI rather than embedding the hosted widget.
  • You need fine-grained control over theming, positioning, and lifecycle events.
Terminal window
npm install @univerx/client-sdk

Before initialising the SDK you need a widget key. Create one in your Univerx dashboard under Settings → Widgets. Each key is tied to a set of allowed domains, so make sure to add your site’s origin there too.

Store the key as an environment variable so it is not committed to source control:

Terminal window
UNIVERX_WIDGET_KEY=your-widget-key-here

The minimal flow is: instantiate → init → submit pre-call form (optional) → join queue → handle events.

import { WidgetClient } from "@univerx/client-sdk";
const widget = new WidgetClient({
widgetKey: "your-widget-key-here", // required
// baseUrl defaults to https://api.univerx.ai
});
// Initialise: authenticates with the Univerx API and sets up realtime channels
await widget.init();
// (optional) collect visitor details before placing them in the queue
await widget.submitForm({
name: "Jane Smith",
email: "jane@example.com",
});
// join the support queue; pass consent flags your pre-call form collected
const ticket = await widget.joinQueue({
terms: true, // visitor accepted terms of service
recording: false, // visitor declined recording consent
});
console.log("Queue position:", ticket.position);
// react to key lifecycle events
widget.on("agent:assigned", (agent) => {
console.log(`Connected to agent: ${agent.name}`);
});
widget.on("call:started", () => {
console.log("Video call is live");
});
widget.on("call:ended", () => {
widget.destroy(); // clean up listeners and connections
});
import { WidgetClient } from "@univerx/client-sdk";
import { useEffect, useRef } from "react";
export function SupportWidget() {
const widgetRef = useRef<WidgetClient | null>(null);
useEffect(() => {
const widget = new WidgetClient({
widgetKey: process.env.UNIVERX_WIDGET_KEY,
onAgentAssigned: (agent) => console.log(`Agent: ${agent.name}`),
onCallEnded: () => widgetRef.current?.destroy(),
});
widget.init();
widgetRef.current = widget;
return () => {
widgetRef.current?.destroy();
};
}, []);
// The SDK renders its own UI; this component is a lifecycle wrapper only
return null;
}
OptionTypeRequiredDescription
widgetKeystringYesYour widget installation key
baseUrlstringNoAPI base URL. Defaults to https://api.univerx.ai
containerstring | HTMLElementNoMount the widget inside a specific DOM element
themeWidgetThemeNoVisual customisation: colors, position, font
cursorCursorConfigNoAgent cursor visibility settings
onReady() => voidNoCalled when the SDK is initialised and ready
onError(error: Error) => voidNoCalled on any unhandled SDK error
onAgentAssigned(agent: Agent) => voidNoCalled when an agent accepts the session
onCallStarted() => voidNoCalled when the video call begins
onCallEnded() => voidNoCalled when the video call ends

The SDK extends EventEmitter. Subscribe with widget.on(event, handler).

EventPayloadDescription
readySDK initialised
queue:joinedQueueTicketVisitor entered the queue
queue:updatenumberQueue position changed
queue:leftVisitor left the queue
agent:assignedAgentAgent accepted the session
call:startedVideo call is live
call:endedVideo call finished
cobrowse:startedCobrowsing session started
cobrowse:endedCobrowsing session ended
errorErrorUnhandled error

Your widget key is missing or incorrect. Double-check the value passed to widgetKey. Also ensure the domain you are running from is allowlisted under Settings → Widgets → Domains in your dashboard.

The queue may be empty or no agents are currently online. Check the Queues section of your dashboard and verify the widget is assigned to the correct queue under Settings → Widgets.

Your domain must be added to the widget’s allowed-domain list. Open Settings → Widgets, select your widget, and add your full origin including protocol (e.g. https://example.com).

The public init endpoint is rate-limited to 10 requests per minute per IP. Avoid calling widget.init() on every render — call it once on component mount and keep the instance alive.