Realtime chess on Cloudflare Workers
A ranked chess arena at the edge.
Match with a human, challenge Edge Bot when the queue is quiet, earn Elo, and let a Durable Object govern every board with authoritative state.
Why Durable Objects
One match, one authoritative coordinator.
Realtime moves
Players and spectators connect over hibernatable WebSockets, so idle thinking time stays cost-efficient.
Strong state
Each match stores FEN, clocks, move history, and chat in SQLite-backed Durable Object storage.
Server validation
The browser proposes moves; chess.js inside the Durable Object decides what is legal.
Architecture
Workers serve the frontend. Durable Objects own the game.
The Matchmaker Durable Object pairs players by time control, then creates a named ChessMatch Durable Object. That match instance becomes the single source of truth for the board, timers, chat, and spectators.
- Client 01 Browser Astro pages, board UI, chat, clocks
- Edge runtime 02 Astro Worker Routes static assets, APIs, WebSocket upgrades
- Coordination 03 Matchmaker DO Pairs players, starts bot games, records Elo
- Match state 04 ChessMatch DO Validates moves, owns clocks, broadcasts state
- Persistence 05 SQLite + WS Durable game records and hibernated sockets
Competitive polish
Every win has weight.
A final result triggers Elo updates, a dramatic result overlay, and confetti for winners. If no human is waiting, Edge Bot keeps the board alive.
Ready
Take the next seat.
Join the queue, or spin up a bot match instantly. The board is already waiting at the edge.
Play now