How to make a web game multiplayer
Updated 2026-11-08
Short answer: you need three things: a way for players to find each other (invite links or matchmaking), a server that relays messages between them, and netcode that keeps their games in step. You can build all three yourself, use a framework for the server, or use a hosted SDK that does all three. With Joinable, the hosted route is one script tag and one call, and your game's code stays almost as it is.
<script async src="https://relay.getjoinable.com/sdk.js" data-connect="invite"></script>
No key while you build. On localhost Joinable works without one, free, in rooms of up to 4 players. Before the game goes live on a real site, get a key free at getjoinable.com/app and add data-key="pk_…" to the tag. Set theme to your game's own colours and font too: Joinable's waiting room, countdown and results then look like part of your game (the kit's "Match the game's look").
(window.JoinableQ = window.JoinableQ || []).push((Joinable) => {
Joinable.game({
profile: 'score',
start({ seed }) { newRound(seed); }, // every player gets the same seed
go() { running = true; },
local() { return { score }; },
stop() { showMenu(); },
});
});
// when the round ends:
window.Joinable?.finish({ score });
That gives players a play-online button, invite links, quick match with strangers, a waiting room, a synced 3-2-1, live scores, one results screen and rematch.
The four ways, compared
| You write | You run | Good for | |
|---|---|---|---|
WebSockets yourself (Node + ws or Socket.IO) | Server, rooms, lobby, reconnects, netcode, UI | A server, forever | Learning; unusual games |
| A server framework (Colyseus, Nakama) | Server room code and client code | Their server, or their cloud | Games that need a trusted server: anti-cheat, hidden information, persistent worlds |
| A hosted state API (PlayroomKit, Photon Realtime) | Client code that reads and writes shared state or events | Nothing | New games designed around the API |
| A hosted session SDK (Joinable) | A few hooks: start from a seed, report your player, draw the others | Nothing | Existing games; solo developers; games built with coding agents |
Peer-to-peer WebRTC on its own isn't a fifth option: you still need a server for signalling and a TURN relay for the players whose networks block direct connections.
Which kind of multiplayer does your game need?
The genre decides the netcode. Pick by what your game is, not by what's easiest to code.
| Your game | What works | With Joinable |
|---|---|---|
| Racer, time trial, runner | Each player owns their car; others are predicted between updates | Full rounds, race profile |
| Anything with a score or a time | Everyone plays the same seeded round; scores are compared live | Full rounds, score profile |
| Board, card, puzzle, clicker, builder, drawing | One shared world; one player's device runs it | Pattern A: often data-sync="game" on the script tag |
| Platformer, top-down, party game | Each player has an avatar in one world | Pattern B |
| Turn-based | Shared world, plus whose turn it is | Pattern A with a turn check |
| RTS with many units | Deterministic lockstep: send inputs only | lockstep profile (Tiny Front) |
| Fighting game | Rollback netcode | Not yet |
| Competitive shooter | A trusted server with lag compensation | Not yet |
Doing it with Joinable, step by step
- No key to start. On localhost and other local sites Joinable works with no key, free and never counted. Before going live, get a key free at getjoinable.com/app and add your site's address to it.
- Add the script tag above,
async, so the game starts at once even if Joinable can't load. - Wire the hooks for your game's pattern. The agent kit has each one with code. Or give your coding agent this prompt from your game's folder: ``
text Make this web game multiplayer using the Joinable SDK (project key pk_…). Read https://getjoinable.com/AGENTS.md first and follow it exactly.`` - Seed your randomness. Anything random that changes the level, the course or the spawns must come from the round's
seed, so every player gets the same game. - Test it:
npx getjoinable test http://localhost:5173/opens two headless players and checks the whole round: same seed, players see each other, one result, rematch. - Try one real round on two devices, a phone and a laptop, on different networks.
Where this stops working
- Cheating. One player's device runs shared worlds, and players report their own scores. Fine for friends and casual leaderboards; not for ranked play with prizes.
- Twitch timing. Other players are predicted between updates, 20 a second. Racing and party games feel right; a 1v1 fighting game wouldn't.
- Huge worlds. Shared-world sync sends changes 20 times a second. A world with thousands of moving units needs the
lockstepprofile instead, and lockstep needs a deterministic simulation: seeded randomness, no clock, fixed ticks. The self-test checks it. - The game must run in a browser. Native desktop and console builds aren't supported.
FAQ
Do I need a server? No. Joinable's relay runs the rooms, matchmaking and messages.
Does it work with my engine? Anything that runs in a browser page: Phaser, three.js, PlayCanvas, Babylon.js, PixiJS, plain canvas, and engines that export to the web, like Godot, through a small JavaScript bridge. Guides: Phaser, three.js, PixiJS, PlayCanvas, Babylon.js, plain canvas.
Will my game still work offline? Yes, if you load the script async and guard calls with window.Joinable?.. The kit's tests check that a never-loading Joinable leaves the game playable.
Can my coding agent set it up? Yes. That's what the agent kit and the MCP server are for.