sinch-rtc
v2.46.9
Published
RTC JavaScript/Web SDK
Keywords
Readme
Sinch RTC SDK for JavaScript
The Sinch RTC SDK enables real-time voice and video calling directly in web applications. It provides a complete client-side solution for building in-app calling experiences in the browser.
Features
- App-to-App Calling — High-quality voice and video calls between users in your application
- App-to-PSTN Calling — Call regular phone numbers directly from the browser
- App-to-SIP Calling — Connect to SIP endpoints for enterprise telephony integration
- App-to-Conference Calling — Join multi-party conference calls from the browser
Prerequisites
- Register a Sinch account
- Create an application in the Dashboard to obtain an Application Key and Application Secret
Installation
npm install sinch-rtcQuick Start
import { Sinch } from "sinch-rtc";
const sinchClient = Sinch.getSinchClientBuilder()
.applicationKey("YOUR_APP_KEY")
.userId("YOUR_USER_ID")
.build();
sinchClient.addListener({
onClientStarted: (client) => {
console.log("Sinch client started");
},
onClientFailed: (client, error) => {
console.error("Sinch client failed", error);
},
onCredentialsRequired: (client, registrationCallback) => {
// Fetch a signed JWT from your backend and pass it to the callback.
// Never embed the Application Secret in client-side code.
fetch("/api/sinch-jwt?userId=YOUR_USER_ID")
.then((res) => res.json())
.then(({ jwt }) => registrationCallback.register(jwt));
},
});
sinchClient.start();Please find more about how to generate JWT in our documentation.
Making a Call
const callClient = sinchClient.getCallClient();
callClient.addListener({
onIncomingCall: (client, call) => {
call.answer();
},
});
const call = callClient.callUser("REMOTE_USER_ID");
call.addListener({
onCallProgressing: (call) => {
console.log("Ringing...");
},
onCallEstablished: (call) => {
console.log("Call established");
},
onCallEnded: (call) => {
console.log("Call ended");
},
});Key Components
| Component | Description |
| --------------- | ------------------------------------------------------------------------------------------------------ |
| SinchClient | Primary entry point — manages configuration, authentication, and feature controllers |
| CallClient | Exposes APIs to place and receive calls, notifies about incoming call events |
| Call | Represents an active call with methods for answering, declining, and hanging up |
| Listeners | SinchClientListener, CallClientListener, and CallListener provide callbacks for state and events |
Documentation
License
ISC
