Stage Management
This guide explains how to use stage management APIs for Interactive Livestream (LHLS) and Webinar (WebRTC) use cases in Cloudflare RealtimeKit.
Instead of a traditional publish-subscribe model, where a user can publish their media and others can choose to subscribe, RealtimeKit comes with an optional managed configuration. In this managed configuration, a less privileged user can be configured with a default behavior to not publish media. The user can then request permission to be allowed to publish their media, where a privileged user can choose to grant or deny access.
Using RealtimeKit's stage management APIs, a user can perform actions such as:
- Leave and join stage
- Manage stage requests and permissions
- Kick participants
The stage module can be accessed under the meeting.stage namespace.
console.log("Stage object:", meeting.stage);The stage module can be accessed under the meeting.stage namespace.
console.log("Stage object:", meeting.stage);The meeting.stage.status property returns the current stage status of the local user.
console.log("Stage status:", meeting.stage.status);Possible status values:
ON_STAGE- The user is currently on the stage and participating in the live streamOFF_STAGE- The user is viewing the live stream but is not on the stageREQUESTED_TO_JOIN_STAGE- The user has a pending request to join the livestream. This status is assigned until the host accepts or rejects their requestACCEPTED_TO_JOIN_STAGE- The host has accepted the user's request to join the livestream
The meeting.stage.status property returns the current stage status of the local user.
console.log("Stage status:", meeting.stage.status);Possible status values:
ON_STAGE- The user is currently on the stage and participating in the live streamOFF_STAGE- The user is viewing the live stream but is not on the stageREQUESTED_TO_JOIN_STAGE- The user has a pending request to join the livestream. This status is assigned until the host accepts or rejects their requestACCEPTED_TO_JOIN_STAGE- The host has accepted the user's request to join the livestream
RealtimeKit's stage management APIs allow hosts to receive and manage stage requests as well as leave and join the stage.
This method connects the user to the media room, enabling them to interact with other peers in the meeting.
await meeting.stage.join();By employing this method, the user will be disconnected from the media room and subsequently unable to communicate with their peers. Additionally, their audio and video will no longer be visible to others in the room.
await meeting.stage.leave();A privileged user can grant access to stage for a set of users with the grantAccess method.
await meeting.stage.grantAccess(userIds);Parameters:
userIds(string[]) - Array of user IDs to grant stage access. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
A privileged user can deny access to stage for a set of users with the denyAccess method.
await meeting.stage.denyAccess(userIds);Parameters:
userIds(string[]) - Array of user IDs to deny stage access. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
A privileged user can remove a set of users from stage using the kick method.
await meeting.stage.kick(userIds);Parameters:
userIds(string[]) - Array of user IDs to remove from stage. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
This method connects the user to the media room, enabling them to interact with other peers in the meeting.
await meeting.stage.join();By employing this method, the user will be disconnected from the media room and subsequently unable to communicate with their peers. Additionally, their audio and video will no longer be visible to others in the room.
await meeting.stage.leave();A privileged user can grant access to stage for a set of users with the grantAccess method.
await meeting.stage.grantAccess(userIds);Parameters:
userIds(string[]) - Array of user IDs to grant stage access. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
A privileged user can deny access to stage for a set of users with the denyAccess method.
await meeting.stage.denyAccess(userIds);Parameters:
userIds(string[]) - Array of user IDs to deny stage access. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
A privileged user can remove a set of users from stage using the kick method.
await meeting.stage.kick(userIds);Parameters:
userIds(string[]) - Array of user IDs to remove from stage. You can retrieve user IDs usingmeeting.participants.toArray().map(p => p.userId)
RealtimeKit's stage management APIs allow participants to request and manage stage access.
This method is used to create a new stage request which can be approved by the host. Each user (viewer or host) must call this method in order to join the stage.
When the host calls this method, their status will be updated to ACCEPTED_TO_JOIN_STAGE.
await meeting.stage.requestAccess();You can call this method to cancel your stage request.
await meeting.stage.cancelRequestAccess();This method is used to create a new stage request which can be approved by the host. Each user (viewer or host) must call this method in order to join the stage.
When the host calls this method, their status will be updated to ACCEPTED_TO_JOIN_STAGE.
await meeting.stage.requestAccess();You can call this method to cancel your stage request.
await meeting.stage.cancelRequestAccess();The meeting.stage module emits the following events:
Emitted when there is an update to stage access requests.
meeting.stage.on("stageAccessRequestUpdate", (data) => { console.log("Stage access request updated:", data);});Emitted when present requests are accepted.
meeting.stage.on("acceptPresentRequests", (data) => { console.log("Present requests accepted:", data);});Emitted when the stage status changes.
meeting.stage.on("stageStatusUpdate", (status) => { console.log("Stage status updated:", status);});Emitted when a new stage request is received.
meeting.stage.on("newStageRequest", (request) => { console.log("New stage request:", request);});Emitted when a stage request is approved.
meeting.stage.on("stageRequestApproved", (data) => { console.log("Stage request approved:", data);});Emitted when a stage request is rejected.
meeting.stage.on("stageRequestRejected", (data) => { console.log("Stage request rejected:", data);});The meeting.stage module emits the following events:
Emitted when there is an update to stage access requests.
meeting.stage.on("stageAccessRequestUpdate", (data) => { console.log("Stage access request updated:", data);});Emitted when present requests are accepted.
meeting.stage.on("acceptPresentRequests", (data) => { console.log("Present requests accepted:", data);});Emitted when the stage status changes.
meeting.stage.on("stageStatusUpdate", (status) => { console.log("Stage status updated:", status);});Emitted when a new stage request is received.
meeting.stage.on("newStageRequest", (request) => { console.log("New stage request:", request);});Emitted when a stage request is approved.
meeting.stage.on("stageRequestApproved", (data) => { console.log("Stage request approved:", data);});Emitted when a stage request is rejected.
meeting.stage.on("stageRequestRejected", (data) => { console.log("Stage request rejected:", data);});Alternatively, you can use React hooks to listen for stage updates:
import { useRealtimeKitSelector } from "@cloudflare/realtimekit-react";
// useRealtimeKitSelector hook only works when `RealtimeKitProvider` is used.const stageStatus = useRealtimeKitSelector((m) => m.stage.status);Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-