Getting Started with JavaScript SDK

The SignalWire JavaScript SDK transforms your standard browser into a realtime media engine, enabling developers to directly make audio and video calls to other browsers. Using the JavaScript SDK you can add immersive, scalable communication - all available right in your own web pages and applications.

SignalWire's simple and powerful authentication system, using JWT, allows you to set granular permissions, enabling some of your users to only join conference calls, while others could list ongoing calls and jump in to assist from a support dashboard... the possibilities are endless.

Using the SDK

First step to using the SDK is to setup authentication. The JavaScript SDK is unique in that everything runs within the browser on the client side, which means, for security, you must use a server-side request to generate a Room Token.

SignalWire JWT Room Tokens are generated via the SignalWire API. You can find out more information about generating Room Tokens at Create Room Token.

Join a room

Using a Video Room Token, you can then join a room from the JS client:

const roomSession = new SignalWire.Video.RoomSession({
  token: '<YourJWT>',
  rootElement: document.getElementById('myRoot'), // an html element to display the video
  audio: true,
  video: true,
})

try {
  await roomSession.join()
} catch (error) {
  console.error('Error', error)
}
const roomSession = new SignalWire.Video.RoomSession({
  token: '<YourJWT>',
  rootElement: document.getElementById('myRoot'), // an html element to display the video
  audio: true,
  video: true,
})

roomSession.join().then(() => {
  // Use roomSession ...
}).catch(error => {
  console.error('Error', error)
})

You can then use roomSession to interact with the room.


Did this page help you?