Skip to main content
Version: 1.x.x

Leave or End Meeting - Javascript

A participant can choose to leave a meeting without removing all the other participants. This is typically done using the Leave Meeting functionality.

Alternatively, if the participant is the host or the last person remaining in the session, they can choose to End Meeting by removing all other participants, which will end the session for everyone.

note

This page uses the following asynchronous methods. Refer to their API reference for the errors each Promise may reject with, and handle these rejections appropriately based on your use case.

leave()

To leave the meeting without removing all the participants, you need to call the leave() method which is a part of the meeting object.

end()

To end the meeting by removing all the participant you need to call the end() method which is a part of the meeting object.

note

These methods can be called only after the meeting is joined successfully.

Example

let meeting;

// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});

const leaveBtn = document.getElementById("leaveBtn");

leaveBtn.addEventListener("click", async () => {
// Leave Meeting
try {
await meeting?.leave();
} catch (err) {
console.error("leave failed:", err);
}

// Exit Meeting
try {
await meeting?.end();
} catch (err) {
console.error("end failed:", err);
}
});
tip

You should call the leave() method on the unmount of your main meeting component so that meeting is left once the view is unmounted.

Events associated with the leave() method.

Following callbacks are received when a participant leaves the meeting.

Events associated with the end() method.

Following callbacks are received when a participant ends the meeting.

let meeting;

// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});

meeting.on("meeting-left", () => {
//Meeting Left
});

meeting.on("participant-left", (participant) => {
//Participant Left the meeting
});

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