nice-napkin-15455
08/13/2025, 9:27 PMtall-airline-16756
08/13/2025, 9:27 PMtall-airline-16756
08/13/2025, 9:27 PMnice-napkin-15455
08/13/2025, 9:29 PMtall-airline-16756
08/13/2025, 9:30 PMControlBar
component.
Here’s a friendly step-by-step on how to do it:
1. Create a Custom Leave Button:
import { useRoomContext } from "@livekit/components-react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { X } from "react-feather";
export default function CustomLeaveButton() {
const room = useRoomContext();
const router = useRouter();
const handleLeave = async () => {
await room.disconnect();
// Just swap '/your-custom-url' with wherever you want to send users
router.push('/your-custom-url');
};
return (
);
}
2. Pop Your Custom Button into the ControlBar:
<ControlBar controls={{ leave: true }}>
<CustomLeaveButton />
</ControlBar>
Just a heads-up: this example uses Next.js for routing. If you’re working with a different routing setup, you might need to tweak the redirection part a bit.
If you hit any bumps or want a hand getting this set up in your app, just shout—I’m here to help!nice-napkin-15455
08/13/2025, 9:36 PMtall-airline-16756
08/13/2025, 9:36 PMControlBar
, you can simply pass the controls
prop with leave
set to false
. This way, the default leave button will be hidden, but all your other controls will stay just as they are.
Here’s a quick example for you:
<ControlBar controls={{ leave: false }} />
Once you do this, only your custom leave button will show up. If you have any questions or need a hand with anything else, just let me know—I’m here to help!
Sources: packages/react/src/components/controls/DisconnectButton.tsxnice-napkin-15455
08/13/2025, 9:37 PMleave: false
no leave buttons shows up. my customleavebutton eithertall-airline-16756
08/13/2025, 9:38 PMControlBar
after you’ve disabled the built-in leave button, you’ll want to add your custom button directly to the ControlBar
component. Here’s a simple way to do it:
1. Create a Custom Leave Button:
import { useRoomContext } from "@livekit/components-react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { X } from "react-feather";
export default function CustomLeaveButton() {
const room = useRoomContext();
const router = useRouter();
const handleLeave = async () => {
await room.disconnect();
router.push('/your-custom-url');
};
return (
);
}
2. Integrate the Custom Button into the ControlBar:
import { ControlBar as BaseControlBar } from "@livekit/components-react";
import CustomLeaveButton from "./CustomLeaveButton";
export function ControlBar({ controls, ...props }) {
return (
);
}
Just be sure to explicitly include your custom button inside the ControlBar
component. That way, it’ll show up nicely even when the default leave button is turned off.
If anything’s unclear or you want a hand with this, just let me know—I’m happy to help!