Skip to main content

SuperVizRoomProvider API Reference

The Room provider is the core element enabling real-time, multi-user interactions within your application. By adding a room provider, you create a virtual space where users, or "participants," can join to collaborate in real-time.

How to use

To add the Room provider, you can follow our quickstart guide.

<SuperVizRoomProvider
developerKey={DEVELOPER_KEY}
group={{
id: "GROUP_ID",
name: "GROUP_NAME",
}}
participant={{
id: "USER_ID",
name: "USER_NAME",
}}
roomId="ROOM_ID">

</SuperVizRoomProvider>

Properties

NameTypeDescription
developerKeystringRequired. Your Developer KEY. If you don’t have a Developer KEY, you can see how to obtain one on the developer portal in our "Setting Up Your Account" section in our documentation.
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.
groupGroupRequired. You can organize your participants into groups. Usually, a group is a company or organization. See the group section for more details.
participantParticipantRequired. User details of the participant in the room. See the Participant section for more details.
debugbooleanEnable SDK logs in the browser console.

Default value: false
stopAutoStartbooleanStops the room from starting automatically when the component is mounted. When using true, you'll need to start the room manually using the startRoom.

Default value: false

Hooks

useSuperViz

startRoom

Type: () => void

It gives the user control over when to start the room and connects the local participant to the room.

To complement this, there is a parameter when creating the room provider, the stopAutoStart.

Example:

const { startRoom } = useSuperViz();

return <button onClick={startRoom}>Start Room</button>;

stopRoom

Type: () => void

It gives the user control over when to stop the room and disconnects the local participant from the room.

Example:

const { stopRoom } = useSuperViz();

return <button onClick={stopRoom}>Stop Room</button>;

hasJoinedRoom

Type: boolean

It returns a boolean value indicating whether the local participant has joined the room, indicating that the room is active.

Example:

const { hasJoinedRoom } = useSuperViz();

return <div>{hasJoinedRoom ? "Room is active" : "Room is not active"}</div>;

Events

onParticipantLocalJoined

Type: (participant: Participant) => void

This event will be dispatched when the local participant enters the room.

Example:

const onParticipantLocalJoined = (participant) => {
console.log("Local participant joined", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantLocalJoined={onParticipantLocalJoined}>

</SuperVizRoomProvider>
)

onParticipantLocalUpdated

Type: (participant: Participant) => void

This event will be dispatched when there is any change to the local participant.

Example:

const onParticipantLocalUpdated = (participant) => {
console.log("Local participant updated", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantLocalUpdated={onParticipantLocalUpdated}>

</SuperVizRoomProvider>
)

onParticipantLocalLeft

Type: (participant: Participant) => void

This event will be dispatched when the local participant leaves the room.

Example:

const onParticipantLocalLeft = (participant) => {
console.log("Local participant left", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantLocalLeft={onParticipantLocalLeft}>

</SuperVizRoomProvider>
)

onParticipantJoined

Type: (participant: Participant) => void

This event is dispatched when any participant enters the room.

Example:

const onParticipantJoined = (participant) => {
console.log("Participant joined", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantJoined={onParticipantJoined}>

</SuperVizRoomProvider>
)

onParticipantListUpdated

Type: (participant: Participant) => void

This event is dispatched whenever there is a change to the list of participants in the room.

Example:

const onParticipantListUpdated = (participant) => {
console.log("Participant list updated", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantListUpdated={onParticipantListUpdated}>

</SuperVizRoomProvider>
)

onParticipantLeft

Type: (participant: Participant) => void

This event is dispatched when any participant leaves the meeting room.

Example:

const onParticipantLeft = (participant) => {
console.log("Participant left", participant);
};

return (
<SuperVizRoomProvider
...
onParticipantLeft={onParticipantLeft}>

</SuperVizRoomProvider>
)

Type Definitions

Avatar

Type: object

While the SuperViz SDK provides a range of default 3D avatars for meetings, you have the flexibility to enrich this experience by adding your custom avatar for participants.

NameTypeDescription
imageUrlstringOptional.

Path to the thumbnail image of the 3D model.
Supported formats: .png and .jpg.
model3DUrlstringOptional.

Path to a 3D model. Only applicable when using Presence3D components
Supported formats: .glb and .gltf.

Example:

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

If you don’t have an avatar you can use the default avatars that we provide in the meeting setup, or you can create them on our Ready Player Me, as our code is optimized to work with their 3D models.

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.COMMENTScommentsContextual Comments
ComponentNames.PRESENCEpresenceIndicates that any presence component is active (Mouse-Pointers, Who-is-Online, or Real-time Data Engine).
ComponentNames.PRESENCE_AUTODESKpresence3dAutodeskPresence 3D Autodesk
ComponentNames.PRESENCE_MATTERPORTpresence3dMatterportPresence 3D Matterport
ComponentNames.PRESENCE_THREEJSpresence3dThreejsPresence 3D Three.js
ComponentNames.REALTIMErealtimeReal-time Data Engine
ComponentNames.VIDEO_CONFERENCEvideoConferenceVideo Conference
ComponentNames.WHO_IS_ONLINEwhoIsOnlineWho-is-Online

Group

Type: object

You can organize your participants into groups, typically representing companies or organizations.

NameTypeDescription
idstringOptional. A unique ID that identifies the group. Usually, this ID matches your internal ID of a specific company or organization.
namestringOptional. The name of the group.

Example:

group: {
id: "GROUP_ID",
name: "GROUP_NAME",
}

Participant

Type: object

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

NameTypeDescription
idstringRequired. Identifier of the participant who is entering the room. Usually, this ID matches the internal ID of your users.
avatarAvatarParticipant avatar information.
namestringRequired. The name of the participant who will enter the room.

Example:

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