Join Meeting - React
Overview
With our React SDK, you can choose to manually call the join()
method or leave it up to the VideoSDK to automatically call it when the MeetingProvider
is rendered.
Before joining the meeting, it has to be initialized. If you have not initialized a meeting yet, you can follow the guide here.
join()
- To join a meeting you can call the
join()
method which is the part of theuseMeeting
hook of React SDK. - This method can be called after the meeting is initialized from the
MeetingProvider
.
caution
useMeeting
hook mentioned above is accessible within the MeetingProvider
only.
import { MeetingProvider, useMeeting } from "@videosdk.live/react-sdk";
const App = () => {
//... Meeting Provider code
};
const MeetingView = () => {
//Getting the join method from hook and assigning event callbacks
const { join } = useMeeting();
const handleJoinMeeting = () => {
// Joining Meeting
join();
};
return (
<>
<button onClick={handleJoinMeeting}>Join Meeting</button>
</>
);
};
Events associated with the join() method
Following events are received when a participant successfully joins a meeting.
- The Local Participant will receive an
onMeetingJoined
event, when the meeting is successfully joined. - The Remote Participant will receive an
onParticipantJoined
event with the newly joinedParticipant
object from the event callback.
import { useMeeting } from "@videosdk.live/react-sdk";
const MeetingView = () => {
//Event to determine if the meeting has been joined
function onMeetingJoined() {
console.log("onMeetingJoined");
}
//Event to determine some other participant has joined
function onParticipantJoined(participant) {
console.log(" onParticipantJoined", participant);
}
//Getting the join method from the hook and assigning event callbacks
const { join } = useMeeting({
onMeetingJoined,
onParticipantJoined,
});
return <>...</>;
};
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord