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 :
Roomornull - The joined room. It is
nulluntiljoin()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
Participantobject for the local participant (you).
participants
- type :
MapofParticipantMap<participantId, Participant>
- Every participant in the room, including the local participant.
- To read a participant's streams and mic or camera state, pass its
participantIdtouseParticipant().
pinnedParticipants
- type :
Map<string, { cam: boolean, share: boolean }> - Maps the
participantIdof every pinned participant to what is pinned: their camera, their screen share, or both.
activeSpeakerId
- type :
string | null - The
participantIdof the participant speaking now, ornullwhen nobody is. - It changes with
onSpeakerChanged.
presenterId
- type :
string | null - The
participantIdof the participant sharing their screen, ornullwhen nobody is. - It changes with
onPresenterChanged.
isMicEnabled
- type :
boolean truewhile the local participant's microphone is on.
isCamEnabled
- type :
boolean truewhile the local participant's camera is on.
isScreenSharing
- type :
boolean truewhile the local participant is sharing their screen.
e2eeEnabled
- type :
boolean trueonce 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 thedeviceIdonly. - It is
nullwhen the SDK picked the camera, or when you passed a custom track.
selectedMicrophoneDevice
- type :
MicrophoneDeviceInfo | null - The microphone in use. It carries the
deviceIdonly. - It is
nullwhen the SDK picked the microphone, or when you passed a custom track.
hlsUrls
- type :
Object- playbackHlsUrl:
string | null - livestreamUrl:
string | null
- playbackHlsUrl:
- The URLs of the room's HLS stream. They are set when
hlsStatebecomesHLS_PLAYABLEand cleared when it becomesHLS_STOPPED.
hlsState
- type :
string - The state of the room's HLS stream, one of the
Constants.hlsEventsvalues. HLS_PLAYABLEis the state in whichhlsUrlscan be played.
liveStreamState
- type :
string - The state of the room's livestream, one of the
Constants.livestreamEventsvalues.
recordingState
- type :
string - The state of the room's recording, one of the
Constants.recordingEventsvalues.
isRecording
- type :
boolean truewhile the room is being recorded.
transcriptionState
- type :
string - The state of realtime transcription, one of the
Constants.transcriptionEventsvalues.
translationState
- type :
string - The state of realtime translation, one of the
Constants.translationEventsvalues.
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
| Field | Type | Description |
|---|---|---|
id | string | The room id. |
localParticipant | Participant | The local participant. |
participants | Map<string, Participant> | Every participant by id, the local participant included. |
roomState | string | null | The connection state, one of Constants.RoomState. null until the first onRoomStateChanged. |
e2eeEnabled | boolean | true once media is end-to-end encrypted. |
Methods
getAppliedVideoConfig(): resolves the camera settings in use,{ width, height, frameRate, facingMode, codec, applied }, ornulluntil the camera has opened once.codecis the codec in use, which can differ from the one you asked for.appliedisfalsewhile the camera is off.setVideoEffects(config),getAppliedVideoEffectsConfig(): the same as the top-levelsetVideoEffects()andgetAppliedVideoEffectsConfig().setWebcamQuality(quality): the same assetWebcamQuality()onuseRoom().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 auseRoom()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

