Skip to main content
Version: 2.x.x

useRoom Hook Properties - React Native

Reading a property subscribes the component to it, so the component re-renders when that value changes.

roomId​

  • type : string | null
  • The id of the room.

room​

  • type : Room or null
  • The joined room. It is null until join() has created it.
  • Use it for what useRoom() does not return, such as the camera settings in use. See Room object.

Example​

const { room } = useRoom();

const showCameraConfig = async () => {
const config = await room?.getAppliedVideoConfig();
console.log("Camera settings in use:", config);
};

localParticipant​

  • type : Participant | null
  • The Participant object for the local participant (you).

participants​

  • type : Map of Participant
    • Map<participantId, Participant>
  • Every participant in the room, including the local participant.
  • To read a participant's streams and mic or camera state, pass its participantId to useParticipant().

pinnedParticipants​

  • type : Map<string, { cam: boolean, share: boolean }>
  • Maps the participantId of every pinned participant to what is pinned: their camera, their screen share, or both.

activeSpeakerId​

  • type : string | null
  • The participantId of the participant speaking now, or null when nobody is.
  • It changes with onSpeakerChanged.

presenterId​

  • type : string | null
  • The participantId of the participant sharing their screen, or null when nobody is.
  • It changes with onPresenterChanged.

isMicEnabled​

  • type : boolean
  • true while the local participant's microphone is on.

isCamEnabled​

  • type : boolean
  • true while the local participant's camera is on.

isScreenSharing​

  • type : boolean
  • true while the local participant is sharing their screen.

e2eeEnabled​

  • type : boolean
  • true once your media is end-to-end encrypted, not merely when a key provider is set. See E2EE.

selectedCameraDevice​

  • type : CameraDeviceInfo | null
  • The camera you picked with changeCam(). It carries the deviceId only.
  • It is null when the SDK picked the camera, or when you passed a custom track.

selectedMicrophoneDevice​

  • type : MicrophoneDeviceInfo | null
  • The microphone in use. It carries the deviceId only.
  • It is null when the SDK picked the microphone, or when you passed a custom track.

hlsUrls​

  • type : Object
    • playbackHlsUrl: string | null
    • livestreamUrl: string | null
  • The URLs of the room's HLS stream. They are set when hlsState becomes HLS_PLAYABLE and cleared when it becomes HLS_STOPPED.

hlsState​

  • type : string
  • The state of the room's HLS stream, one of the Constants.hlsEvents values.
  • HLS_PLAYABLE is the state in which hlsUrls can be played.

liveStreamState​


recordingState​


isRecording​

  • type : boolean
  • true while the room is being recorded.

transcriptionState​


translationState​

tip

To know when you have joined the room, use onRoomJoined. To follow the connection state, use onRoomStateChanged, or read room.roomState.

Room object​

useRoom().room is the joined room. useRoom() already returns its state and its methods, and the hooks such as usePubSub() and useRealtimeStore() cover the rest. Use room only for the members below.

Its fields read the current value each time you access them. They do not re-render your component, so read the matching useRoom() property when you render.

Fields​

FieldTypeDescription
idstringThe room id.
localParticipantParticipantThe local participant.
participantsMap<string, Participant>Every participant by id, the local participant included.
roomStatestring | nullThe connection state, one of Constants.RoomState. null until the first onRoomStateChanged.
e2eeEnabledbooleantrue once media is end-to-end encrypted.

Methods​

  • getAppliedVideoConfig(): resolves the camera settings in use, { width, height, frameRate, facingMode, codec, applied }, or null until the camera has opened once. codec is the codec in use, which can differ from the one you asked for. applied is false while the camera is off.
  • setVideoEffects(config), getAppliedVideoEffectsConfig(): the same as the top-level setVideoEffects() and getAppliedVideoEffectsConfig().
  • setWebcamQuality(quality): the same as setWebcamQuality() on useRoom().
  • on(eventType, listener), off(eventType, listener): add and remove a listener for a room event by its hyphenated name, such as "participant-joined" or "room-left". Every one of these events is also a useRoom() callback, which is the way to use them inside a component.
const { room } = useRoom();

const showCameraConfig = async () => {
const config = await room?.getAppliedVideoConfig();
if (config?.applied) {
console.log(config.width, config.height, config.codec);
}
};

Got a Question? Ask us on discord