Case study · Web platform
Gamio
A browser-based gaming platform for Unity WebGL games, with zero downloads and real-time multiplayer over WebRTC.
Overview
A full-stack platform that lets people play Unity WebGL games directly in the browser, then join the same lobby from another machine.
Games are served from Cloudflare R2 storage, and multiplayer sessions are established through WebRTC peer-to-peer connections. A Cloudflare Workers signalling server handles lobby management and NAT traversal.
Architecture
The frontend is React 19 with Vite, backed by Cloudflare Workers with Durable Objects for real-time WebSocket signalling. R2 stores Unity WebGL builds and game assets.
The game catalogue auto-discovers content by scanning R2 buckets for
setup.txt metadata files, so publishing a build does not require a
frontend deploy.
Frontend
React 19, Vite, Unity WebGL loader and a game catalogue UI.
Edge
Cloudflare Workers, Durable Objects, WebSocket signalling.
Storage
Cloudflare R2 for builds, assets and setup metadata.
Transport
WebRTC data channels with TURN and STUN for NAT traversal.
Real-time multiplayer
A WebSocket signalling server manages lobby creation with five-character invite codes, host/client architecture and player management. WebRTC carries the actual peer-to-peer game data, with TURN server integration for NAT traversal and STUN fallback.
The host/client split keeps a single player authoritative for game state while keeping the signalling layer thin and replaceable.
Unity integration
I built a bidirectional Unity–JavaScript bridge for communication between the React frontend and Unity WebGL instances. Dynamic script injection loads builds on demand, with automatic cleanup on page unload and progress tracking for loading states.
The hard parts were lifecycle and cleanup: a WebGL canvas that survives a route change will happily leak memory, so the bridge owns creation and teardown rather than leaving it to the page.
Challenges solved
- Unity–JavaScript communication through a custom event-driven bridge.
- NAT traversal using Cloudflare TURN servers across different network configurations.
- Dynamic asset loading with script injection for Unity WebGL instances.
- Real-time state synchronisation across multiple players in a lobby.