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 rtcexpress

Initialize 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:

  1. Your backend gives each signed-in user one token without a roomId.
  2. After init, join one room per contact, named from both user IDs in sorted order, for example dm_alice__bob. Join them one at a time and wait for roomJoined each time.
  3. To call Bob, join dm_alice__bob again (it becomes the current room), wait for roomJoined, then call.
  4. The incoming call says whether it is voice or video (callType): ask for camera permission only for video.
Don't scope a token to one contact's roomThe user could then be called only by that one person. Rooms named 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

Keep authorization on your serverUse HTTPS in production. Request camera and microphone access only when the user starts a call.

Test two real devices, permission denial, network switching, background behavior, and reconnects. Record the call ID and UTC time for diagnostics.