/ SDKs / React Native
Calls SDKs React Native v1
Calls SDKs React Native
Calls SDKs
React Native
Version 1

Enter and exit a room

Copy link

A user can search a room with a specific room ID to participate in a group call at any time. When a user enters a room, a participant is created with a unique participant ID to represent the user in the room.

To enter a room, you must first acquire the room instance from Sendbird server with the room ID. To fetch the most up-to-date room instance from the Sendbird server, use the SendbirdCalls.fetchRoomById() method. Also, you can use the SendbirdCalls.getCachedRoomById() method that returns the most recently cached room instance from Sendbird Calls SDK.

// Get a room instance using ROOM_ID.
const room = await SendbirdCalls.fetchRoomById(ROOM_ID);

// Get a cached room instance using ROOM_ID.
const room = await SendbirdCalls.getCachedRoomById(ROOM_ID);

Note: A user can enter the room using multiple devices or browser tabs. Entering from each device or browser tab will create a new participant.

Once the room is retrieved, call the enter() method to enter the room. An object that sets whether to use video and audio is passed to enter() as a parameter. If no parameters are passed, both audio and video are enabled as default.

If you create a room using SendbirdCalls.createRoom(), you can use the returned room instance without needing to get a room instance.

const enterParams: EnterParams = {
    audioEnabled: true,
    videoEnabled: true,
await room.enter(enterParams)

To leave a room, call exit(). On the room handlers of the remaining participants, the onRemoteParticipantExited() method will be called.