Skip to main content
Version: 2.x.x

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​

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 roomId is optional. An option you leave out takes the SDK default.

    • type: Object
    • REQUIRED

The options are listed under Config options.


token​

  • The auth token generated from your server.

    • type: String
    • REQUIRED

To generate a token, see this documentation.

important

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
important

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

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

participantId​

  • Your own id for this participant.

    • type: String
    • default: a random 8-character string
    • OPTIONAL

micEnabled​

  • Whether the participant's microphone is on when they join. You can turn it on or off later.

    • type: Boolean
    • default: true
    • OPTIONAL

camEnabled​

  • Whether the participant's camera is on when they join. You can turn it on or off later.

    • type: Boolean
    • default: true
    • OPTIONAL
note

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 of Constants.Mode

    • default: SEND_AND_RECV

    • OPTIONAL


multiStream​

  • Whether to send several resolution layers of the camera. Set it to false to send a single layer.

    • type: Boolean
    • default: true
    • OPTIONAL
  • This applies to the camera the SDK opens for you. A customCameraTrack uses its own multiStream setting.


customCameraTrack​


customMicrophoneTrack​


metaData​

  • Extra details about the participant, such as a profile image. Other participants read it as participant.metaData.

    • type: Object
    • default: null
    • OPTIONAL

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 customCameraTrack keeps its own facingMode.


maxResolution​

  • The size at which the SDK opens the camera. hd opens it at 1280x720 and sd at 960x540. A customCameraTrack keeps its own encoderConfig.


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: true and the VP8 codec. See Simulcast.

    • type: Boolean
    • default: false
    • OPTIONAL

autoConsume​

  • When true, you receive each remote participant's microphone and camera as soon as they turn them on. When false, you receive them only after you call consumeMicStreams() or consumeWebcamStreams() from useParticipant() for that participant. This saves bandwidth in large rooms.

  • consumeMicStreams(), consumeWebcamStreams(), stopConsumingMicStreams() and stopConsumingWebcamStreams() take effect only when the room was created with autoConsume set to false.

    • type: Boolean
    • default: true
    • OPTIONAL

enableBatching​

  • Whether pub-sub messages are delivered in batches.

    • type: Boolean
    • default: true
    • OPTIONAL

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

translationLanguage​

  • The language this participant receives translated text in, as a language code such as es or en-GB. If you do not set it, this device receives no translated text. To change it during the session, call changeTranslationLanguage() from useTranslation().

    • type: String
    • OPTIONAL

signalingBaseUrl​

  • The base URL of your own signalling server, for example behind a proxy. Leave it out to use VideoSDK's.

    • type: String
    • OPTIONAL

preferredProtocol​

  • The network protocol for media.

    • UDP_OVER_TCP tries UDP first and switches to TCP if that fails.

    • UDP_ONLY uses only UDP.

    • TCP_ONLY uses 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

note

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