Skip to main content
Version: Version 2.0

Room

The Room component is the core element enabling video conference within your application. By integrating a room, you create a virtual space where users, or "participants," can join a video conference room.

How to use

To initialize the Room component, you can follow our quickstart guide.

Usage

To add a room to your application, use the following code:

import { createRoom } from "@superviz/room";

async function initializeSuperVizRoom() {
const room = await createRoom({
developerToken: DEVELOPER_TOKEN,
roomId: "ROOM_ID",
participant: {
id: "USER_ID",
name: "USER_NAME",
},
group: {
id: "GROUP_ID",
name: "GROUP_NAME",
}
});

return room;
}

When initializing a room you must pass parameters for it to work properly. See below the available parameters:

NameTypeDescription
developerTokenstringRequired. Your develper token. You can find it on your dashboard.
roomIdstringRequired. This is a unique ID that you can create on your end. Using the same ID you will be able to enter the same room. Minimum length of 2 characters and maximum of 64.

Accepted pattern: [-_&@+=,()\{\}\\[\\]\/«».:|'"#a-zA-Z0-9À-ÿ\s]*
participantParticipantRequired. An object describing the user that will participate in the room.
debugbooleanEnable SDK logs in the browser console.
Default value: false

Methods

Once you've initialized, you'll have access to methods that allow you to interact with the SDK and perform various tasks. Below are the methods available.

addComponent

The addComponent method allows you to add a component such as video conference to the room. You can add multiple components to the same room including components from SuperViz collaboration.

Example:

const video = new VideoConference({
participantType: 'host'
});

room.addComponent(video);

Parameters:

TypeDescription
componentRequired. Pass the component instance you want to add to the room.

removeComponent

The removeComponent method allows you to remove a component from the room.

Example:

// if a video instance has been added to the room, then we can remove it
room.removeComponent(video);

getParticipants

Retrieves the list of participants in the room.

Example:

room.getParticipants().then((participants) => {
console.log("Participants:", participants);
});

Returns: Promise<Participant[]>

On the callback function, you will receive the following argument:

TypeDescription
Participant[]Array of participants in the room

Example:

[
{
"id": "USER_ID_1",
"email": "USER_EMAIL",
"name": "USER_NAME",
"activeComponents": ['videoConference'],
"type": "host",
"avatar": {
"imageUrl": "https://<PATH>",
}
},
{
"id": "USER_ID_2",
"email": "USER_EMAIL",
"name": "USER_NAME",
"activeComponents": ['videoConference'],
"type": "host",
"avatar": {
"imageUrl": "https://<PATH>",
}
},
];

leave

If you wish to leave the room and destroy its components, you can use the leave method. Here's how to use it:

room.leave();

Events

RoomEvent

You can subscribe to the following Room events:

EventString EquivalentDescription
UPDATE
'room.update'
Triggered when the room updates.
ERROR
'room.error'
Triggered when an error occurs.

* Note for CDN Users: Use the string equivalent directly in room.subscribe().

UPDATE

Triggered when the room updates.

Usage Example:

room.subscribe(RoomEvent.UPDATE, onRoomUpdate);

function onRoomUpdate(roomState) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
RoomStateRoom state that triggered the event.

Example:

{
"status": RoomState.CONNECTED
}

ERROR

Triggered when an error occurs.

Usage Example:

room.subscribe(RoomEvent.ERROR, onRoomError);

function onRoomError(error) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
RoomErrorRoom error that triggered the event.

Example:

{
"code": "auth_error",
"message": "[SuperViz] Room initialization failed: this website's domain is not whitelisted."
}

ParticipantEvent

You can subscribe to the following Participant events:

EventString EquivalentDescription
MY_PARTICIPANT_JOINED
'my-participant.joined'
Triggered when the local participant enters the room.
MY_PARTICIPANT_LEFT
'my-participant.left'
Triggered when the local participant leaves the room.
MY_PARTICIPANT_UPDATED
'my-participant.updated'
Triggered when the local participant updates.
PARTICIPANT_JOINED
'participant.joined'
Triggered when a participant enters the room.
PARTICIPANT_LEFT
'participant.left'
Triggered when a participant leaves the room.
PARTICIPANT_UPDATED
'participant.updated'
Triggered when a participant updates.

* Note for CDN Users: Use the string equivalent directly in room.subscribe().

MY_PARTICIPANT_JOINED

Triggered when the local participant enters the room.

Usage Example:

room.subscribe(ParticipantEvent.MY_PARTICIPANT_JOINED, onMyParticipantJoined);

function onMyParticipantJoined(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantParticipant that triggered the event by entering the room.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

MY_PARTICIPANT_LEFT

Triggered when the local participant leaves the room.

Usage Example:

room.subscribe(ParticipantEvent.MY_PARTICIPANT_LEFT, onMyParticipantLeft);

function onMyParticipantLeft(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantParticipant that triggered the event by leaving the room.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

MY_PARTICIPANT_UPDATED

Triggered when the local participant updates.

Usage Example:

room.subscribe(ParticipantEvent.MY_PARTICIPANT_UPDATED, onMyParticipantUpdated);

function onMyParticipantUpdated(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantParticipant that was updated.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

PARTICIPANT_JOINED

Triggered when a participant enters the room.

Usage Example:

room.subscribe(ParticipantEvent.PARTICIPANT_JOINED, onParticipantJoined);

function onParticipantJoined(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantThe participant details that had joined the room triggered the event.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

PARTICIPANT_LEFT

Triggered when a participant leaves the room.

Usage Example:

room.subscribe(ParticipantEvent.PARTICIPANT_LEFT, onParticipantLeft);

function onParticipantLeft(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantThe participant details that had left the room triggered the event.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

PARTICIPANT_UPDATED

Triggered when a participant updates.

Usage Example:

room.subscribe(ParticipantEvent.PARTICIPANT_UPDATED, onParticipantUpdated);

function onParticipantUpdated(participant) {
// do something
}

On the callback function, you will receive the following argument:

TypeDescription
ParticipantParticipant that was updated.

Example:

{
"id": "USER_ID",
"name": "USER_NAME",
"activeComponents": [],
"slot": {
"index": 2,
"color": "#878291",
"textColor": "#fff",
"colorName": "gray",
"timestamp": 1736161104631
}
}

Type Definitions

Participant Initialization

Type: object

An object describing the participant information, like name and avatar.

NameTypeDescription
idstringIdentifier of the participant who is entering the room. Usually, this ID matches the internal ID of your users. Minimum length of 2 characters and maximum of 64.

Accepted pattern: [-_&@+=,()\{\}\\[\\]\/«».:|'"#a-zA-Z0-9À-ÿ\s]*
emailstringThe email of the participant who will enter the room.
namestringThe name of the participant who will enter the room.
avatarAvatarParticipant avatar information.

Example:

{
"id": "USER_ID",
"email": "USER_EMAIL",
"name": "USER_NAME",
"avatar": {
"imageUrl": "https://<PATH>",
"model3DUrl": "https://<PATH>",
}
}

RoomError

Type: object

An object describing the room error.

NameTypeDescription
codestringThe error code.
messagestringThe error message.

Example:

{
"code": "auth_error",
"message": "[SuperViz] Room initialization failed: this website's domain is not whitelisted."
}

RoomState

Type: object

An object describing the room state.

NameTypeDescription
statusstringThe room state. Options: CONNECTED, CONNECTING, DISCONNECTED, CONNECTION_ERROR, RECONNECTING, RECONNECT_ERROR

Example:

{
"status": "CONNECTED"
}

Participant

Type: object

An object describing the participant information, like name and avatar.

NameTypeDescription
idstringIdentifier of the participant who is entering the room. Usually, this ID matches the internal ID of your users. Minimum length of 2 characters and maximum of 64.

Accepted pattern: [-_&@+=,()\{\}\\[\\]\/«».:|'"#a-zA-Z0-9À-ÿ\s]*
emailstringThe email of the participant who will enter the room.
activeComponentsComponentNames[]List of active components that the participant has entered.
namestringThe name of the participant who will enter the room.
avatarAvatarParticipant avatar information.

Example:

{
"id": "USER_ID",
"email": "USER_EMAIL",
"name": "USER_NAME",
"activeComponents": ['videoConference'],
"type": "host",
"avatar": {
"imageUrl": "https://<PATH>",
}
}

ComponentNames

Type: enum

List of possible components that a participant can be added to. This is a read-only property, to add a participant into a component, you should use the addComponent method of the room. The options are:

NameValueComponent
ComponentNames.VIDEO_CONFERENCEvideoConferenceVideo Conference or Video Huddle
ComponentNames.WHO_IS_ONLINEwhoIsOnlineWho-is-Online
ComponentNames.COMMENTScommentsContextual Comments
ComponentNames.PRESENCEpresenceMouse Pointers
ComponentNames.PRESENCE_AUTODESKpresence3dAutodeskPresence 3D Autodesk
ComponentNames.PRESENCE_MATTERPORTpresence3dMatterportPresence 3D Matterport
ComponentNames.PRESENCE_THREEJSpresence3dThreejsPresence 3D Three.js

Avatar

Type: object

Avatars represent participants within a room. In typical scenarios, they appear as profile images when used with Who-is-Online and Contextual Comments.

In 3D spaces (e.g., Matterport, Autodesk viewer or ThreeJs), avatars can take the form of 3D digital representations.

NameTypeDescription
imageUrlstringRequired. Path to the thumbnail image of the 3D model.
Supported formats: .png and .jpg.
model3DUrlstringPath to a 3D model. Only applicable when using Presence3D components
Supported formats: .glb and .gltf.

Example:

avatar: {
imageUrl: "https://<PATH>",
model3DUrl: "https://<PATH>",
}