tall-fountain-87900
03/03/2026, 12:16 PMtall-airline-16756
03/03/2026, 12:16 PMtall-airline-16756
03/03/2026, 12:17 PMroom.disconnect() when the button is clicked. That terminates the local participant’s connection and LiveKit will emit participantDisconnected to other participants.
Example (JavaScript/TypeScript):
// assume `room` is your connected LiveKit Room instance
document.getElementById('leave-button')?.addEventListener('click', () => {
room.disconnect(); // triggers participantDisconnected for others
});
2) If the button is in an admin dashboard and should remove another participant (backend-driven):
• Have the button call your server API (authenticated). On the server use the server SDK’s remove/kick API (e.g., roomService.removeParticipant(roomName, identity)).
• That forces the target participant to disconnect and causes participantDisconnected to be emitted to other clients.
3) Listening for the event (on other clients):
room.on('participantDisconnected', (participant) => {
console.log('Participant disconnected:', participant.identity);
// update UI, cleanup tracks, etc.
});
Key notes
• The event is generated by LiveKit when a participant actually disconnects — you can’t manually synthesize the event from the client.
• If you need an “instant” UI change on the admin who clicked the button, update that client’s UI immediately while the server-side removal proceeds; the event will propagate to everyone else.
If you want, tell me which setup you’re using:
• Are you implementing a self-leave button (client-side) or an admin “kick” (server-side)?
• Which SDK/language are you using for the server (Node, Go, etc.)?
I’ll give exact code snippets for your stack.
Sources: client-sdk-js | livekit/livekit_composite | DeepWiki | server-sdk-js | livekit/livekit_composite | DeepWiki