How to make an .io or arena game multiplayer
Updated 2026-11-23
Short answer: an .io or arena game gives every player an avatar in one shared world. The common browser approach is host-authoritative input: each player sends their inputs, one simulation moves every avatar, and the world is synced to everyone. Joinable does this without a server of your own (Pattern B in its kit), and it suits casual arenas, top-down and party games for up to 16 players a room. It is not the right tool for a 100-player .io arena or a competitive shooter, and this page says why.
Two kinds of ".io game"
People mean two different things:
- The classic .io: one big public arena, dozens or hundreds of strangers, drop in any time, play for minutes. Agar.io and its descendants.
- The small arena: 2 to 8 friends or strangers in one room, avatars in a shared world: top-down brawlers, co-op dungeon runs, party games, platformers.
The second is what Joinable is built for. The first needs a different architecture: a server running the world at a fixed tick, interest management (each player only gets what's near them), and rooms far bigger than Joinable's. If that's your game, a server framework like Colyseus is a better fit, and you'll run it yourself.
How avatars work with Joinable
Pattern B in the kit:
- Your single
playerbecomes a map keyed by player id, kept in the synced state:game.players = {}. - Every player sends their own input (left, right, jump) to the host whenever it changes.
- Only the host simulates. It moves every avatar from their latest input, runs enemies, pickups and scoring, and the world syncs to everyone 20 times a second.
- If the host leaves or switches tabs, the next player takes over at any frame, because everything the simulation needs is in the synced state.
The room keeps a copy of the world, so late joiners arrive in the current game.
The code
Joinable.sync(game, { local: ['keys'] });
const inputs = {}; // host only: latest input per player id
let lastSent = '';
function sendInput() {
const me = Joinable.me;
if (!me) return;
const mine = { left: keys.left, right: keys.right, jump: keys.jump };
if (Joinable.isHost) inputs[me.id] = mine;
else if (JSON.stringify(mine) !== lastSent) {
lastSent = JSON.stringify(mine);
Joinable.send({ input: mine }, Joinable.hostId);
}
}
Joinable.on('message', (data, from) => { if (data?.input) inputs[from] = data.input; });
// host only: an avatar for every player, and none for players who left
Joinable.on('players', (players) => {
if (!Joinable.isHost) return;
for (const p of players) game.players[p.id] ??= { id: p.id, x: 100, y: 100, color: p.color, name: p.name };
for (const id of Object.keys(game.players)) if (!players.some((p) => p.id === id)) delete game.players[id];
});
function update(dt) {
sendInput();
if (Joinable.me && !Joinable.isHost) return; // guests: the host's world arrives by itself
for (const [id, p] of Object.entries(game.players)) movePlayer(p, inputs[id] ?? {}, dt);
// …the rest of your update: enemies, spawns, scoring
}
Draw every avatar in its color, so players can tell each other apart. Before connecting, Joinable.me is null and the game plays solo as before. Star Catcher is a complete example; its changes are marked MP:.
Load the script with <script src="https://relay.getjoinable.com/sdk.js">. No key is needed on localhost; before going live, get one free at getjoinable.com/app.
Where this stops working
We'd rather you know before you start:
- Player count. A room holds up to 4 players on the free Sandbox plan on a live site, 8 on Starter and Pro, and 16 on Studio. There are no 100-player arenas. If more people open an invite link than fit, the next one is told the room is full.
- Input delay for guests. Guests feel about one round trip between pressing a key and their avatar moving. A room lives near its first player: friends on one continent typically see 20–80 ms to it, players across oceans 150–250 ms. Fine for party and casual games. Instant movement for each player's own avatar is on the SDK's roadmap, not built.
- Twitch shooters. Competitive shooters need a trusted server with lag compensation (it rewinds time to check whether your shot hit where you saw the target). Joinable doesn't run game code on its side, so it isn't the tool for them yet.
- Cheating. The host runs the world, so the host can cheat. Fine between friends, not for ranked play.
- Huge worlds. The whole world is sent as changes 20 times a second. Thousands of moving objects is too much; a strategy game with that many units should use lockstep instead.
Make it feel good anyway
- Keep per-device things local: pressed keys, mouse, camera, UI state, audio. List them under
local. - Give entities ids (
id: game.nextId++), so removals hit the right one. - Plain data, not class instances. Entities created on a guest reach the host as plain objects without methods.
- Use
requestAnimationFrame. Phaser, PixiJS and three.js all do underneath. AsetIntervalloop is a common reason sync fails.
Arena games with rounds
If your arena game is really a score attack (everyone in their own copy of the same seeded level, racing for points), the score profile is simpler and gives you the waiting room, 3-2-1, live scores and one leaderboard for free. See score games. If it's a race, see racing games.
Test it
Open the game on localhost in two windows side by side (not background tabs: browsers throttle them, and the host role moves). Check that both show the same world, that each player's input moves their own avatar on both screens, and that closing the host's window leaves the other playing. A third window opened late should get the current world. Or give the prompt to your coding agent.
FAQ
Can I make an agar.io-style game with Joinable?
Not one with dozens or hundreds of players in one arena. Joinable's rooms hold up to 16 players on Studio, and the world is synced from one player's device. Small arenas of 2 to 16 work; massive public arenas need a server you run.
Is there input lag for other players?
The host's own avatar moves at once. Every other player feels about one round trip of delay between their key press and their avatar moving. That suits casual and party games; it doesn't suit a competitive shooter.
Do I need a server for a multiplayer arena game?
No. Joinable's hosted relay runs the rooms, invites, host changes and late joiners. One player's device runs the world; you write no server code.
What happens when the host leaves?
The next player becomes host and the world carries on from the synced state. Write the host code so any player can take over at any frame, which mostly means keeping everything the simulation needs in the synced state.