JAVASCRIPT / TYPESCRIPT
Web voice & video call SDK (JavaScript)
Use the browser SDK for room chat, 1:1 and group voice and video calls, and screen sharing in modern WebRTC-capable browsers. Published on npm as rtcexpress.
Before you start
Authenticate the user in your own backend, decide whether they may enter the room, and request a short-lived RTC token. The client receives that token and never receives the App Secret.
Install
Install the rtcexpress package from npm, or download the starter and follow the voice calling tutorial for a working app.
npm install rtcexpressInitialize and join a room
import { RTCExpress } from "rtcexpress";
const rtc = new RTCExpress();
await rtc.init({ serverUrl, appId, userId, token, mediaMode: "auto" });
rtc.on("roomJoined", () => rtc.sendMessage("Hello"));
rtc.joinRoom("support-room-42");Calling people in your app
A call happens inside a room: the caller must have joined it, and on Starter and Pro the person being called must be a member too. For an app where users call their contacts:
- Your backend gives each signed-in user one token without a
roomId. - After
init, join one room per contact, named from both user IDs in sorted order, for exampledm_alice__bob. Join them one at a time and wait forroomJoinedeach time. - To call Bob, join
dm_alice__bobagain (it becomes the current room), wait forroomJoined, then call. - The incoming call says whether it is voice or video (
callType): ask for camera permission only for video.
dm_<userA>__<userB> are private: only those two users can join them, so chat history and calls stay between the pair. For a single fixed room (a support chat, one meeting) create the token with that roomId instead.Production notes
Test two real devices, permission denial, network switching, background behavior, and reconnects. Record the call ID and UTC time for diagnostics.