Skip to content

Self-hosting the room

A built deck is a static site: copy dist/ to any host and it works, offline features and all. Two things need a server:

  • the live room (following, polls, quizzes, questions, reactions, shared drawing): use deck.kadal.cc, or run your own room server against the protocol below;
  • the phone remote on a static host, which needs only a tiny message relay: kadal-deck relay. A deck with a room pairs the phone through the room instead.

The deck’s live client talks to live.api (/api by default, same origin) and joins the room named by live.room (the deck’s slug when unset). A room server answers:

Path What
GET {api}/rooms/{room}/ws the room, as a WebSocket. ?role=presenter or viewer, or remote for a phone remote; t= carries a Turnstile token when the room requires one; ticket= (a presenter ticket) or pass= (a viewer’s pass from the host’s check page) when the host issues them
GET {api}/rooms/{room} a read-only snapshot: position and presence
GET {api}/decks/{room}/presenter { required, ok, passcode, signIn }: does the presenter view need a passcode, is this window a presenter, can a passcode open it, and where its author signs in instead
POST {api}/decks/{room}/presenter/login · /logout { passcode } → { ok, ticket? }: a host may answer with a presenter ticket (kept in the page), set a presenter cookie, or both
POST {api}/decks/{room}/beacon { viewer, dwell, enters } from each viewer, for time-per-slide analytics
GET {api}/decks/{room}/stats the stats page’s data (presenter only)
POST {api}/decks/{room}/share { h, v, click?, label? } → a short link to a slide
POST {api}/decks/{room}/exports?kind=pdf · GET …/exports · GET …/exports/{key} the export archive: a POST stores an exported file, and the stats page lists and downloads them (presenter only; optional)

A host can also serve GET {api}/decks/{room}/ads and POST …/ads/seen for the ad frame deck.kadal.cc puts round free decks; a room server of your own leaves them out and the deck shows no frame.

The presenter’s credentials travel the same way everywhere: as ticket= on the WebSocket, and as an x-deck-ticket header on the presenter-only requests. A ticket arrives in the page’s address fragment (#ticket=…, which no server sees), from the login answer, or from the window that opened this one.

The messages on the WebSocket are typed in the engine. Import them to build a server that can’t drift from the client:

import type { ClientMessage, ServerMessage, RoomState } from "@kadal/deck/protocol";

A client says hello with its role and a viewer ID; the server answers welcome with the full RoomState, then sends state patches and the transient events (nav, pointer, react, draw, term, confetti, zoom). Viewers’ messages that only a presenter may send (nav, poll:open, draw for everyone, session) must be dropped, and every viewer’s traffic throttled.

The phone remote rides the same socket. A presenting window asks for a pairing code (remote:code, a new one about every 30 seconds while its QR is shown); a phone connects with role=remote and says the code in its hello, and the server answers remote:paired with a lease the phone uses to come back. One phone per presenter: pairing a new one sends the old one remote:bye. After that the phone’s command messages go to the presenting window only, and the window’s command:result and remote:state go back to that phone. The rules are written out in live/protocol.ts (PAIRING).

deck.kadal.cc runs on Cloudflare:

  • a Worker (Hono) routes the endpoints above and serves the decks;
  • one Durable Object per room, SQLite-backed, with WebSocket hibernation so an idle room costs nothing between messages; the room’s state is written to the object’s storage, so it survives eviction and a reload;
  • D1 keeps what outlives a room: passcode hashes, sessions, questions, poll results, time per slide, share links;
  • R2 holds the published files and the export archive;
  • Workers rate limiting on passcode attempts and writes.

A room server doesn’t have to be built this way: anything that speaks the WebSocket protocol and answers the endpoints works.

deck.config.ts
export const config = {
live: { api: "https://rooms.example.com/api", room: "q3-review" },
};

live.api is the base of every path above; null makes an offline deck. live.room defaults to the deck’s slug. live.turnstile is a Cloudflare Turnstile site key when your server requires a check before a viewer joins.

The engine is licensed under the AGPL-3.0-or-later. In practice:

  • Presenting with it, publishing decks built with it, and running an unmodified engine trigger nothing.
  • If you run a modified engine as a network service, the people using that service must be able to get your modified source (AGPL §13).
  • A room server you write yourself against the protocol types is your own program.

If those terms don’t suit your product, a commercial licence removes them.

Send feedback