Room Provider - React Native
RoomProvider holds one room for the components inside it. useRoom() and useParticipant() read the room from the nearest RoomProvider.
It is a React context provider. To learn more about context providers, see the React documentation.
RoomProvider
import { RoomProvider } from "@videosdk.live/react-native-sdk";
function App() {
return (
<RoomProvider
config={{
roomId: "room-id",
participantName: "Participant Name",
micEnabled: true,
camEnabled: true,
mode: "SEND_AND_RECV", // "SEND_AND_RECV" | "RECV_ONLY" | "SIGNALLING_ONLY"
defaultCamera: "back", // "front" | "back"
}}
token={"token"}
joinWithoutUserInteraction
>
<RoomView />
</RoomProvider>
);
}
RoomProvider Props
config
-
The room to join. Every option except
roomIdis optional. An option you leave out takes the SDK default.- type:
Object REQUIRED
- type:
The options are listed under Config options.
token
-
The auth token generated from your server.
- type:
String REQUIRED
- type:
To generate a token, see this documentation.
Keep token and provider identifiers consistent. If the authentication token specifies a participantId or roomId, pass the exact same values to the participantId and roomId config options. Mismatched identifiers cause the join request to be rejected as an invalid-token error.
joinWithoutUserInteraction
The joinWithoutUserInteraction prop decides whether to join the room automatically or wait for an explicit join() call.
true — The participant joins the room when RoomProvider mounts. Do not call join() yourself.
false (default) — The participant does not join automatically. Your code must call join().
- type:
Boolean - default:
false OPTIONAL
Use only one join mechanism. joinWithoutUserInteraction and a manual join() call are mutually exclusive. Do not use both.
Config options
roomId
-
Unique Id of the room the participant joins.
- type:
String REQUIRED
- type:
To create a room, see this documentation.
participantName
-
The name other participants see.
- type:
String - default: a random 6-character name, assigned when you join
OPTIONAL
- type:
participantId
-
Your own id for this participant.
- type:
String - default: a random 8-character string
OPTIONAL
- type:
micEnabled
-
Whether the participant's microphone is on when they join. You can turn it on or off later.
- type:
Boolean - default:
true OPTIONAL
- type:
camEnabled
-
Whether the participant's camera is on when they join. You can turn it on or off later.
- type:
Boolean - default:
true OPTIONAL
- type:
On Android, the microphone and camera start only if your app already has microphone and camera access. Request it before you join, as shown in Android Setup.
mode
-
There are 3 modes:
-
SEND_AND_RECV: The participant sends and receives audio and video. -
SIGNALLING_ONLY: The participant neither sends nor receives audio and video, but stays in the room. -
RECV_ONLY: The participant receives audio and video but sends none. -
type:
String, one ofConstants.Mode -
default:
SEND_AND_RECV -
OPTIONAL
-
multiStream
-
Whether to send several resolution layers of the camera. Set it to
falseto send a single layer.- type:
Boolean - default:
true OPTIONAL
- type:
-
This applies to the camera the SDK opens for you. A
customCameraTrackuses its ownmultiStreamsetting.
customCameraTrack
-
A camera track to publish instead of opening the camera again. Create it with
createCameraVideoTrack(). Pass the track you previewed to keep its picture across the join.- type:
CustomStreamTrack OPTIONAL
- type:
customMicrophoneTrack
-
A microphone track to publish. Create it with
createMicrophoneAudioTrack().- type:
CustomStreamTrack OPTIONAL
- type:
metaData
-
Extra details about the participant, such as a profile image. Other participants read it as
participant.metaData.- type:
Object - default:
null OPTIONAL
- type:
defaultCamera
-
The camera the SDK opens first.
-
front- the front-facing (selfie) camera. -
back- the rear-facing (main) camera. -
type:
String -
default:
front -
OPTIONAL
-
-
A
customCameraTrackkeeps its ownfacingMode.
maxResolution
-
The size at which the SDK opens the camera.
hdopens it at 1280x720 andsdat 960x540. AcustomCameraTrackkeeps its ownencoderConfig.- type:
String, one ofConstants.MaxResolution - values:
hd|sd - default:
hd OPTIONAL
- type:
dynaCast
-
When
true, the quality of the camera video you send is lowered while no other participant is watching its larger layers, and raised again when someone is. This saves upload bandwidth. -
It works only with
multiStream: trueand theVP8codec. See Simulcast.- type:
Boolean - default:
false OPTIONAL
- type:
autoConsume
-
When
true, you receive each remote participant's microphone and camera as soon as they turn them on. Whenfalse, you receive them only after you callconsumeMicStreams()orconsumeWebcamStreams()fromuseParticipant()for that participant. This saves bandwidth in large rooms. -
consumeMicStreams(),consumeWebcamStreams(),stopConsumingMicStreams()andstopConsumingWebcamStreams()take effect only when the room was created withautoConsumeset tofalse.- type:
Boolean - default:
true OPTIONAL
- type:
enableBatching
-
Whether pub-sub messages are delivered in batches.
- type:
Boolean - default:
true OPTIONAL
- type:
speakingLanguage
-
The language this participant speaks, as a language code such as
en. Realtime translation uses it as the source language for their speech. You can set it only here.- type:
String OPTIONAL
- type:
translationLanguage
-
The language this participant receives translated text in, as a language code such as
esoren-GB. If you do not set it, this device receives no translated text. To change it during the session, callchangeTranslationLanguage()fromuseTranslation().- type:
String OPTIONAL
- type:
signalingBaseUrl
-
The base URL of your own signalling server, for example behind a proxy. Leave it out to use VideoSDK's.
- type:
String OPTIONAL
- type:
preferredProtocol
-
The network protocol for media.
-
UDP_OVER_TCPtries UDP first and switches to TCP if that fails. -
UDP_ONLYuses only UDP. -
TCP_ONLYuses only TCP. -
type:
String -
values:
UDP_ONLY|UDP_OVER_TCP|TCP_ONLY -
default:
UDP_OVER_TCP -
OPTIONAL
-
codecSwitchEnabled
-
When
true, the SDK falls back to VP8 when a receiver cannot decode the codec you publish.- type:
Boolean - default:
true OPTIONAL
- type:
End-to-end encryption is not a RoomProvider prop. Register a key provider with setKeyProvider() before you join.
Got a Question? Ask us on discord

