Banger Bingo is music bingo for living rooms. The host puts the game on a TV, everyone else joins from their phone's browser by scanning a QR code, and each phone shows a bingo card. The TV plays a hit, and a disco ball picks how it has to be answered: song title, artist, decade, before or after 2000, or the release year within four. Name the exact year and you can steal a square. The first person to finish a line shouts "BANGER!"
I built it to play with my family. Everyone who's played it loves it, so I'm opening it up at banger.bingo.
This post is about how it works under the hood. The whole thing runs on Cloudflare: a Worker for routing, one Durable Object per game room, D1 for host accounts, and Workers Static Assets for the frontend. I'll also cover the part that was harder than any of the code: getting legal access to the music.
How it fits together
Every device opens a WebSocket through a Worker, which routes it to that room's Durable Object. The TV is the only device that plays audio, using the host's Apple Music subscription.
The phones and the TV never talk to each other directly. Everything goes through the room.
One room, one Durable Object
A party game is an awkward shape for a typical backend. A room lives for one game night and then disappears. Up to a dozen phones plus the TV need to agree on its state in real time, and two people can hit BANGER! within the same few milliseconds.
Durable Objects fit that shape well. Each four-letter room code maps to exactly one object through idFromName, so every device that joins with that code reaches the same instance. That instance holds the open WebSockets and the game state, and saves the state to its own storage. Because an object handles one message at a time, two BANGER! taps in the same millisecond are still judged one after the other, with no locks. When the night is over, an alarm closes the room: after two hours with no activity, or 30 minutes after the TV disconnects.
// worker/src/index.ts: the same code always reaches the same room
function roomStub(env: Env, code: string) {
return env.ROOMS.get(env.ROOMS.idFromName(code));
}
// Creating a room: pick a random code; if that room already exists, it answers 409 and we try another
for (let i = 0; i < MAX_CODE_RETRIES; i++) {
const code = generateRoomCode(); // e.g. "KTXV"
const res = await roomStub(env, code).fetch('https://room/init', {
method: 'POST',
body: JSON.stringify({ code, hostToken }),
});
if (res.ok) return Response.json({ code, hostToken });
}
// Joining: every phone and the TV upgrade to a WebSocket on that one object
const match = url.pathname.match(/^\/api\/rooms\/([^/]+)\/ws$/);
if (match && isRoomCode(match[1])) {
return roomStub(env, match[1]).fetch(new Request('https://room/ws', request));
}
idFromName is deterministic: the same code always gives the same ID, so there's no table of rooms to keep. Cloudflare creates the object near the first request that reaches it. That's the host's computer creating the room, which in practice is the one hooked up to the TV, so the room runs close to the people playing.
The bigger win is concurrency. A Durable Object handles one event at a time, so when two phones answer at the same moment, one message is fully processed before the other starts. Each answer gets a timestamp as it's processed. When the round's timer ends, the room settles steals and winners from those timestamps in one pass. Deciding who was first is a sort, not a lock.
One catch: keep the check-and-set tight. Storage calls are protected by the runtime's input gates, but if you await anything else between reading the state and writing the result, such as an outside fetch, other messages can run in that gap. In BANGER! the message handler is fully synchronous. The game state lives in memory, and every change is written with a storage.put that isn't awaited. The output gate holds outgoing messages until the write is confirmed, so no player sees a result that hasn't been saved.
On a traditional Node stack, I'd have reached for Redis pub/sub to fan out messages and some kind of lock to decide who was first. Here, the room is the server.
Keeping the TV and every phone in sync
The room never sends "something changed" messages for devices to apply. After every change, it sends each device a complete picture of the game written for that device's role, and the device just draws it. The TV gets the song to play. A phone gets its own card, the squares it can mark right now, and who it can steal from. Each picture carries a deadline for the current phase and the server's clock time (serverNow). The phone works out how far its own clock is off from the server's and counts down to the server's deadline.
// worker/src/Room.ts: every change ends here
private afterChange(now: number): void {
for (let i = 0; i < MAX_TICKS && this.core.tick(now); i++) this.room.lastActivity = now;
this.scheduleDeadline(); // setTimeout to the next phase change
this.persist(); // storage.put, not awaited
this.broadcast(); // a full view per socket, per role
}
private broadcast(): void {
for (const [ws, role] of this.sockets) {
if (role?.kind === 'display') this.send(ws, { type: 'view', view: displayView(core, code, now) });
else if (role?.kind === 'player') this.send(ws, { type: 'view', view: playerView(core, code, role.playerId, now) });
}
}
// client/src/lib/view.ts + countdown.ts: the phone just draws what it's given
export function applyView(v: DisplayView | PlayerView): void {
view.set(v);
clockOffset.set(v.serverNow - Date.now());
}
export function secondsLeft(deadline: number | null, now: number, offset: number): number {
if (deadline === null) return 0;
return Math.max(0, Math.ceil((deadline - (now + offset)) / 1000));
}
Sending the whole picture costs a few more bytes than sending changes, but it removes a whole class of bugs. A phone can't drift out of step by missing a message, because the next picture replaces everything it had. While anyone is connected, the room also re-sends every picture every five seconds. A phone that dropped a message, or locked its screen and came back, catches up within five seconds without any special reconnect code. Rejoining means opening a new socket and saying hello; the next picture does the rest.
Writing a separate picture for each role also keeps the game honest. Only the TV's picture names the song, so a curious player can't open dev tools and read the answer off the socket. A phone isn't told whether its answer was right until the reveal. The timers belong to the server too: when a phase ends, a setTimeout inside the Durable Object moves the game on, whether or not any phone is paying attention. Phones only display the countdown; they never decide when time is up.
The hard part was the music
The code was the easy part. Getting legal access to hit songs was not.
The first version used Spotify's Web Playback SDK, with the host signing in with Spotify Premium. It worked great with my family. When I tried to open it to the public, I hit two walls. Spotify's developer policy lists games, including trivia quizzes, as a prohibited use. And since May 2025, getting an app out of development mode (capped at 5 users) requires a registered business and at least 250,000 monthly active users.
Next I talked to Feed.fm, which licenses music for apps. Their catalog had around 1,000 to 2,000 hits, against the 6,000-plus songs on my list, and the quote was about $3,000 a month. For a free game in early access, that didn't work.
So Banger Bingo uses Apple Music through MusicKit JS. The host signs in on the TV, and songs play from their own subscription. Players never need an account. Only the TV plays audio, so there's no audio to keep in sync across phones. The phones are just controllers.
The tradeoff is that the host needs an Apple Music subscription, and for now it only works with the US store. Hitster, the music card game, works the same way with Spotify.
The song list itself is hand-curated, from the '60s through 2025, with each song tagged with its original release year so the year questions have a right answer.
What I learned
• Check content licensing before writing code. I had a working game on Spotify before I read the part of its policy that bans games. Read the terms of whatever supplies your content first.
• Design for hibernation from the start. Treat every wake-up as a fresh instance and keep state in storage. Retrofitting that later is a refactor.
• Clean up finished rooms. Durable Object storage persists until you delete it. Calling this.ctx.storage.deleteAll() when a game ends keeps abandoned rooms from piling up.
• One object per room replaces a lot of infrastructure. No pub/sub layer, no locks, no session affinity.
• No app install is a feature. Joining from a phone browser with a QR code means a guest who walks in mid-party can be playing by the next song.
Try it
Banger Bingo is free during early access at banger.bingo. You need a TV or any big screen, 2 to 12 people with phones, and an Apple Music subscription for the host (US store for now).
If you've built something real-time on Durable Objects, I'd like to hear how you handled reconnects and room cleanup. And if you've solved music licensing for a small game, I really want to hear from you.

Top comments (0)