Video meetings
env.CALL gives your app meeting rooms with video, sound, screen sharing and chat. Your server code decides who may join and as what (host, participant or viewer); the browser gets a token and shows a ready-made meeting, on desktop and phone.
env.CALL is available to every workspace and paid as usage, per person per minute. Reference it in any api/*.js file and it's wired up on deploy. For chat, presence or multiplayer without video, use env.ROOM.Let someone in
Only your server code can let someone in, so you decide who gets into which room. The simplest way sends the person to the ready meeting page, which has a camera and microphone check, a grid of people, screen sharing, chat and a participant list, with no front-end work:
// api/join-call.js
export default {
async fetch(request, env) {
const me = await env.AUTH.getUser(request);
if (!me) return new Response("Sign in first", { status: 401 });
const room = new URL(request.url).searchParams.get("room");
const { url } = await env.CALL.room(room).join({
userId: me.id,
name: me.name,
role: "participant", // or "host", "viewer"
});
// The link keeps its #t=... part through the redirect.
return Response.redirect(new URL(url, request.url).toString(), 302);
},
};A link to /api/join-call?room=board-meeting then opens the meeting. Add ?leave=/some/page before the # in url to send people there when they leave. The access is after the #, so it never reaches a server log; treat the whole link as that person's key.
The meeting in your own page
Return the token instead (const { token } = await room.join(...)) and show the meeting with only that token:
<script type="module">
import { defineCustomElements } from "https://cdn.jsdelivr.net/npm/@cloudflare/realtimekit-ui@2.0.3/loader/index.es2017.js";
defineCustomElements();
</script>
<script src="https://cdn.jsdelivr.net/npm/@cloudflare/realtimekit@2.0.4/dist/browser.js"></script>
<!-- The meeting fills the height you give it; leave its display alone. -->
<rtk-meeting id="meeting" show-setup-screen="true" style="height: 100dvh"></rtk-meeting>
<script>
fetch("/api/join-call", { method: "POST", body: JSON.stringify({ room: "board-meeting" }) })
.then((r) => r.json())
.then(({ token }) => RealtimeKitClient.init({ authToken: token }))
.then((meeting) => { document.getElementById("meeting").meeting = meeting; });
</script>React apps can use @cloudflare/realtimekit-react-ui the same way, passing the token to initMeeting({ authToken }).
Reference
| Call | Returns |
|---|---|
env.CALL.room(name, { audioOnly? }) | A room by your own name (1 to 128 letters, digits and _ . : @ -, for example a booking id), made on first join. audioOnly: true makes a sound-only room, which costs less; it's fixed when the room is made. |
room.join({ userId, name?, role?, picture?, expiresIn? }) | { token, url, room, role, audioOnly, expiresAt }. A host can mute, remove and pin people; a participant (the default) takes part; a viewer watches, listens and chats. The token lets that person in for expiresIn seconds (6 hours unless you say, 60 seconds to 100 days); someone already in the meeting stays in. Joining again gives the same person a new token. url is the ready meeting page for them. Give each token only to its person. |
room.participants() | Who is in the meeting now: [{ userId, name, role, joinedAt }]. |
room.remove(userId) | { removed }: that person out now, and their token stops working. A new join() lets them back in, so stop giving them one. |
room.end() | { ended, kicked }: everyone out, the meeting ends. |
room.sessions() | Past meetings in the room: [{ id, startedAt, endedAt, participants, minutes }], filled in within the hour after a meeting ends. |
room.delete() | { deleted }: everyone out, the room goes, its tokens stop working and the names of the people in it are deleted. |
env.CALL.rooms() | Your rooms: [{ name, audioOnly, createdAt, lastJoinedAt }]. |
Preview deploys have their own rooms, apart from production's.
Price
Each person in a meeting counts: $0.005 a minute in a video room and $0.0012 in an audio-only room. A one-hour meeting with five people on video is 300 minutes, $1.50. An empty room costs nothing. See billing.
Privacy
Sound and video go through the meeting service's nearest location to each person, which may be outside the EU. The service keeps a record of each meeting and who took part (names and times) until you delete the room or the app. Tell your users this in your privacy policy if your app holds meetings.
Errors
| code | status | Why |
|---|---|---|
call_error | 400 | A bad room name, user id or role |
call_billing_paused | 402 | The team's apps are paused for billing |
call_unavailable | 503 | Meetings aren't switched on yet |
call_provider_error | 502 | The meeting service didn't answer; try again |