press5 Play: multiplayer for launch pad games
Free multiplayer rooms for browser games published on the press5 launch pad, and for native builds (Godot, Unity, desktop). No server code to write: press5 Play is the master server (matchmaking, room codes, lobbies) and the room server (relay, shared state, host handoff, reconnects).
The 30-second version
- Make the game as a static site (HTML, JS, canvas, Phaser, three.js, a Godot web export...).
- Load the SDK:
<script src="https://play.press5.xyz/sdk/v1/press5-play.js"></script>(orimport Press5Play from 'https://play.press5.xyz/sdk/v1/press5-play.mjs'). - Connect, find a room, sync state:
const play = await Press5Play.connect({ name: 'Ada' });
const room = await play.quickMatch({ maxPlayers: 8 }); // or createRoom({ private: true }) / joinRoom('KXQRTW')
room.setMyState({ x: 100, y: 200 }); // your player's state: everyone sees it
room.onMessage('shoot', (data, from) => spawnBullet(data, from.id));
room.send({ type: 'shoot', angle: 1.2 }); // one-off events to everyone (or room.send(data, playerId))
function frame() {
for (const p of room.others()) draw(room.smoothState(p.id)); // smoothed between network updates
requestAnimationFrame(frame);
}
- Optional: add
press5.game.jsonnext toindex.html(see below). - Deploy like any site (
deploy_site,npx @press5/cli deploy, orPOST https://my.press5.xyz/api/v1/deploys). The game's address (https://<name>.on.press5.xyz) is its identity: pages on that address can connect, nothing else can use its players. - Test: open the url in two browser windows.
Working examples to copy: mp-brawl (a server-run arena), mp-duel (turn-based 1v1 on the turns engine), mp-party (room-code quiz on the party engine), mp-sketch (drawing and guessing on the party engine) and mp-arena (a real-time relay game). Live at https://demo-mp-brawl.on.press5.xyz and the others; files from GET https://my.press5.xyz/api/v1/templates/mp-brawl or get_template. Each has the SDK file next to it.
For AI tools: the checklist
Follow these steps in order and the game works the first time:
- Pick the room type from the game idea:
| The game | Use | Template | | --- | --- | --- | | Real-time action: shooter, brawler, .io, tag, platform fighter | "server": {"engine": "arena"} | mp-brawl | | Board game: four in a row, tic-tac-toe, reversi, checkers, gomoku | "server": {"engine": "turns"} | mp-duel | | Shedding card game with hidden hands | "server": {"engine": "turns", "rules": "card-table"} | mp-duel | | Quiz, trivia, poll, "who said it" | "server": {"engine": "party"} | mp-party | | Quiz with typed answers | "server": {"engine": "party", "mode": "guess"} | mp-party | | Drawing and guessing (one draws a secret word, the rest guess) | "server": {"engine": "party", "mode": "draw"} | mp-sketch | | Anything else (racing, co-op, sandbox, custom rules) | relay room + a "guard" block | mp-arena |
- Start from the template (
get_template) instead of a blank page: it already connects, matches, reconnects and draws. Keep itspress5-play.jsnext toindex.html. - Write press5.game.json with
"$schema": "https://my.press5.xyz/schemas/press5.game.json"at the top, atitle,maxPlayers,"listed": true, a thumbnail, and either the"server"block (settings:engine_reference) or, for a relay game, a"guard"block (format:guard_reference). - Check it:
check_game { manifest }(MCP) orPOST https://my.press5.xyz/api/v1/play/check. Fix every error (each comes with its fix) and read the warnings. Repeat untilokis true. - Deploy with
deploy_site. The reply'smultiplayerfield repeats the check against the live file. - Verify:
game_info { site }shows players, rooms and anything press5 Play noticed (nextsays what to do). Tell the person to open the url in two windows.
When something fails, the error has code, message, fix and docs: apply the fix. Every code: https://my.press5.xyz/docs/multiplayer/errors (JSON: GET https://my.press5.xyz/api/v1/play/errors). TypeScript types for the SDK: https://play.press5.xyz/sdk/v1/press5-play.d.ts. JSON Schema: https://my.press5.xyz/schemas/press5.game.json.
Common mistakes: calling setState when not the host (check room.isHost); using setState/setMyState in a server room (use setInput or act); sending a message every frame (send events, put positions in setMyState); trusting Date.now() for countdowns (use play.serverTime()); a relay game with no guard block (anyone can teleport); ignoring room.on('guard') corrections; putting a secret in shared state (see "Secrets and fair scoring" below). An unclaimed site may be on http:// until it is claimed: there crypto.subtle, the clipboard and WebTransport are missing (the SDK falls back to the WebSocket by itself), so don't depend on them, or ask the person to claim the site.
Two kinds of room: server engines and relay rooms
- Server engines (recommended when one fits): press5 runs the game's rules with its own code, and the game only sends input and actions. Nobody can cheat by editing the page, hidden information (cards, quiz answers) stays hidden, and results go on a leaderboard. Pick one with a
"server"block in press5.game.json. No game code ever runs on press5: an engine is press5's, the game only sets it up. - arena: real-time 2D action (top-down, or side-on with gravity): movement, walls, projectile and hitscan weapons, pickups, teams, rounds. Your own movement is predicted so it feels instant; shots are lag-compensated. For a map with walls where hiding matters, set
"world": {"lineOfSight": true}: players behind walls are never sent to a client, so no wall hack can show them (add"viewRadius"too on big maps). With press5 Guard and a view radius,"decoys": truealso sends players Guard has already flagged a few made-up enemies at the edge of their view radius, off-screen: only a radar or wall hack shows them, and aiming at them confirms the flag. Keep the camera's view under about 85% ofviewRadiusand don't draw enemies on a minimap. - turns: board and card games with rule packs:
connect-n,tic-tac-toe,reversi,checkers,free-grid,card-table(hidden hands). Turn order, a turn clock, resigning, rematches, spectators. - party: quiz and poll rounds, quizzes with typed answers (
"mode": "guess", matched loosely), and drawing and guessing games ("mode": "draw": players take turns drawing a secret word; only the drawer is sent it, only their strokes count, guesses are judged on press5). Questions, answers and words never reach players early. - Every setting, its default and its limit: the
engine_referencetool, orGET https://my.press5.xyz/api/v1/play/engines. - Relay rooms (any other game): press5 passes messages and shared state between players and picks a host; the host player's page runs the rules. Fine for casual games; the host could cheat.
Server engines
{ "title": "Ember Brawl", "maxPlayers": 12, "listed": true, "rated": false,
"server": { "engine": "arena", "world": { "width": 1600, "height": 1000, "walls": [[700, 470, 200, 40]] },
"players": { "speed": 280, "hp": 5 }, "weapons": [{ "id": "blaster", "speed": 760, "cooldownMs": 200 }],
"pickups": [{ "id": "orb", "count": 12, "score": 1 }], "rounds": { "durationS": 180, "scoreToWin": 30 } } }
const play = await Press5Play.connect({ name });
const room = await play.quickMatch();
// arena: controls in, the world out
room.setInput({ mx, my, ax: mouseX - me.x, ay: mouseY - me.y, fire: mouseDown });
const me = room.mine(); // you, predicted: { x, y, hp, dead, score, ... }
room.entities().forEach(drawPlayer); // everyone else, smoothed
room.shots(); room.rays(); room.pickups(); room.round(); room.scores();
room.on('ko', (d) => feed(d.by + ' got ' + d.t));
// turns and party: actions in, room.view out
await room.act('move', { x: 3 }); // refused with an error if it is not your turn or not legal
room.on('state', () => draw(room.view));
room.engine.confighas the checked settings (walls, weapons, board size) for drawing; the party engine leaves out its questions. press5.game.json itself is never served to browsers.- Leaderboards: every engine game gets one (
"leaderboard": falseturns it off); only press5's engines write it, from games with at least two players lasting 30 s.play.leaderboard('week'), theleaderboardtool, orGET https://play.press5.xyz/v1/games/{name}/leaderboard. Players are a random signed id kept on their device. Two players can't feed each other points: their results against each other count in full ten times a day, then half as much each time. - Ratings:
"rated": truekeeps an Elo rating per player and quick match pairs players of a similar rating. - Fast transport: in browsers that support it, server rooms send state and inputs as WebTransport datagrams (unreliable, so a lost packet never stalls the game) and fall back to the WebSocket by themselves.
How a relay room works
- Players have
id,name,seat(0, 1, 2... stable while they are in the room),stateandaway. - Host: the longest-connected player. If they leave or drop, the next one takes over at once (
room.onHostChange). The host is where shared game logic runs: spawn pickups, keep score, run the timer, decide who won.room.isHosttells you if it is you. Write host logic so any player can pick it up mid-game, reading everything it needs fromroom.state. - Room state (
room.state, set withroom.setState(patch)): one JSON object everyone sees, written by the host only. - Player state (
room.me.state, set withroom.setMyState(patch)): each player's own object, written only by them. Use it for position, aim, ready flags, chosen character. - Patches merge into the top-level keys;
nullremoves a key. Changes are sent once a tick (the game'stickRate, default 20 a second), so call the setters every frame if you like. Your own changes apply locally at once. - Messages (
room.send(data, to?)): any JSON, to everyone else or to one player id or a list. The sender is stamped by the server (from) so it cannot be faked.room.onMessage('type', fn)filters ondata.type. - Binary (
room.sendBinary(bytes, toSeat?),room.on('binary', (bytes, from) => ...)): the fast path for high-rate games; first byte is added by the SDK. - Lobby:
room.codeis a 6-letter code (no I or O) to share;room.lock()when the match starts (no one new joins, quick match skips it);room.kick(id),room.makeHost(id),room.setMeta({...})(shown in room lists). - Reconnects: a dropped player keeps their seat and state for 30 seconds and the SDK rejoins by itself (
play.on('reconnecting'),play.on('reconnected'); others seeroom.on('away')androom.on('back')). Server restarts keep rooms too. - Clock:
play.serverTime()is the server's clock in ms on every player's machine;play.rttis the round trip.
Events
room.onJoin(p), room.onLeave((p, reason) => ...), room.onHostChange(id), room.onStateChange((keys) => ...), room.on('playerState', (p, keys) => ...), room.onMessage(fn), room.on('away'|'back'|'name'|'meta', ...), room.onEnd(reason) (left, kicked, timeout, connection_lost). Each on... returns a function that unsubscribes.
Matchmaking
play.quickMatch({ mode, maxPlayers, filters, meta }): the fullest open room with the same mode and filters, or a new one.filtersare short exact-match keys, e.g.{ region: 'eu', level: 3 }.play.createRoom({ private, maxPlayers, mode, meta, state }): a room of your own; private ones are joined by code only.play.joinRoom(code),play.listRooms({ mode })(open public rooms, fullest first),play.setName(name).
press5.game.json
{ "title": "Neon Arena", "description": "Top-down arena brawler", "maxPlayers": 12, "modes": ["ffa", "teams"],
"tickRate": 20, "listed": true, "thumbnail": "thumb.png", "tags": ["action", "io"], "guard": { ... } }
All fields are optional. maxPlayers is both the default and the limit for rooms (2-64). modes limits quick match to those modes (the first is the default). listed: true asks to be shown in the public arcade at https://press5.xyz/arcade; it is shown once the site is claimed and has passed the content check. thumbnail is an image on the game's own site (a path like thumb.png); images on other hosts are not shown. The deploy reply's multiplayer field and the game_info tool report mistakes in this file.
press5 Guard: anti-cheat limits (write these for every relay game)
A relay room trusts each player with their own state, so a hacked client could set x anywhere or score to a million. Add a "guard" block to press5.game.json stating what a fair player can never do, and press5 Play holds every setMyState, setState and send to it on the server, instantly:
"guard": {
"me": {
"x": { "min": 0, "max": 1600 }, "y": { "min": 0, "max": 1000 },
"score": { "min": 0, "max": 100000, "int": true, "maxRate": 10, "only": "up", "resetTo": [0] },
"hp": { "min": 0, "max": 100, "resetTo": [100] }, "skin": { "oneOf": ["red", "blue"] }
},
"room": { "round": { "min": 0, "max": 99, "int": true } },
"move": { "x": "x", "y": "y", "maxSpeed": 320, "resets": ["life"] },
"messages": { "perSec": 20, "key": "type", "types": { "shoot": { "perSec": 6, "human": true }, "chat": { "perSec": 1 } } },
"kickAfter": 3
}
- Set the numbers from your own code:
maxSpeedis your player's top speed in world units a second (include dashes and boosts),maxRatethe most a value can change in a second (the most points a second's play can earn),perSecthe fastest a key can really be pressed (the weapon's fire rate). press5 adds 20% for network jitter. - What happens: a value out of range is clamped; a position moving faster than
maxSpeed(a speed hack or a teleport) only gets as far as it could have; a wrong type or a value outsideoneOfis dropped; a message over its rate is not delivered. Players who keep doing it (kickAfterstrikes inside 30 s) are removed, leave the leaderboards for a day, and are locked out of the whole game: 2 minutes, then 15, then 2 hours for each time more in a day. Joining then fails withguard_locked(e.retryMsis how long is left): show it, with a countdown (below). A lag spike doesn't count: speed and rate breaks while a connection catches up after a stall are still clamped, but one stall every 30 s never counts towardskickAfter. - Respawns and new levels: list the keys that change when the player legally jumps (
"resets": ["life"]; bump it in the samesetMyStateas the new position). Then positions may jump and values may go back to theirresetTo. Always add"resetIf": {"key": "dead", "is": true, "forMs": 1200}(a jump only after the player has been dead that long; setdeadwhen they die) and/or"spawns": [{"x": 100, "y": 100, "r": 60}](where a respawn may land), or a hacked client can teleport by bumping the reset key. - Radar hacks: in a relay room every player's position goes to everyone, so a radar hack can show the whole map. If players shouldn't see each other across it, add
"view": {"radius": 800}(withmove): another player's position is then sent only to players near them, and is deleted from your copy of their state when they go out of view (check thatstate.xexists before drawing someone). - Binary frames (
room.sendBinary) count againstmessages.perSec;"binary": falserefuses them, and with"strict": truethey are refused unless"binary": true. - Keep your copy in step, smoothly: when press5 corrects a write, the SDK updates
room.me.stateand firesroom.on('guard', (me, room) => ...). For your own player usevar smooth = room.guardSmooth(player): it puts the corrected values intoplayerat once (so what you send next is what the server has) andsmooth.view()eases where you draw it over 100 ms, so a correction never looks like rubber-banding. Draw atsmooth.view().x,.y(options:{ keys: ['x', 'y'], ms: 100 }). Skip this and a player who lagged keeps sending positions the server won't take. - Tell removed players why: when press5 Guard removes a player the room ends with reason
guard(and how long they are locked out), joining while locked out fails withguard_locked, and a player the game's owner banned getsbanned/guard_banned.Press5Play.guardNotice(reasonOrError, info)turns any of these into a plain message with a countdown (nullfor anything else):
var guardTimer = null;
function showGuard(n) { // n from Press5Play.guardNotice(...)
clearInterval(guardTimer);
function tick() {
statusEl.textContent = n.text(); // "... You can play again in 1:42."
var waiting = n.banned || n.left() > 0;
playButton.disabled = waiting;
if (!waiting || n.banned) clearInterval(guardTimer);
}
tick(); guardTimer = setInterval(tick, 1000);
}
room.onEnd(function (why, info) { var n = Press5Play.guardNotice(why, info); if (n) showGuard(n); });
play.quickMatch().then(enter, function (e) { var n = Press5Play.guardNotice(e); if (n) showGuard(n); else statusEl.textContent = e.message; });
"human": trueon a message kind means a person presses something for each one; with press5 Guard its timing is checked for macros and bots."strict": truerefuses state keys (or message kinds, insidemessages) not listed.- Tuning:
"mode": "watch"only reports.game_infoshowsguard: which rules trip and how often. A rule that over 30% of players break is paused for an hour (it is wrong, not them) and listed underguard.paused: raise it. The game's Anti-cheat page (launch pad, your site) has a Tuning table: the share of players tripping each limit and a suggested number (what 99% of fair players did) to copy into press5.game.json. The same page explains each case, shows its samples, and lets you clear a player or ban a guest id from your game. - Server engines need no guard block: movement, fire rate and input rate are the engine's already.
- Automation monitor (press5 Guard, sold per game): aimbots, triggerbots, autoclickers, speed hacks, wall hacks and bot players are spotted from how they play, across every room they join, judged against your own game's players once there is enough data (a game with huge targets or fast reflexes isn't held to another game's numbers). Server-engine games also get: arena movement scripts (keys held for exactly the same time, the same route over and over), dodging a shot before anyone could have seen it, aim smoothing (an even turn onto the target with no correction), aiming through walls at players the client was never sent (with
lineOfSight), aiming at decoys only a hack would show (withdecoys), knockouts on accounts that stand still (boosting, a second account feeding); party answers shared between two players, and typed guesses that arrive faster than anyone types. Each needs a minimum sample, and the ones that are only hints can never act alone. By default they are kept off the leaderboards;"automation": "kick"removes them (with the same lockout),"report"only reports.
Patterns that work
- Real-time movement: each player moves themselves locally and calls
setMyState({x, y, angle})every frame; draw others withroom.smoothState(id)(about 100 ms behind, smooth). Good for up to ~20 moving players per room. - Things nobody owns (pickups, enemies, the ball): the host simulates them and writes them to
room.state, or sends compact messages; everyone else only draws. Keeproom.statesmall (it is limited to 64 KB). - Turn-based / board games: keep the board in
room.state; players send their move as a message; the host checks it is legal and writes the new board. Anyone can then read whose turn it is fromroom.state. - Party games:
createRoom({ private: true }), showroom.codebig on screen,room.lock()when the host starts. - Cheating: a relay room trusts the host, within the game's
guardlimits (above). Server engines trust nobody. Do not hand out real prizes based on a relay game. - Player text is untrusted: names, chat, messages, room meta and leaderboard names come from other players. Show them with
textContentor canvasfillText, neverinnerHTML.
Native builds (Godot, Unity, desktop)
A native build has no web address to prove which game it is, so it uses a game key: register_game { name, title, site } (MCP, needs sign-in) or POST https://my.press5.xyz/api/v1/play/games returns key (p5g_..., shown once). Tie it to the game's launch pad site and native players share rooms with the web build. Keys ship inside the game: they are the game's identity, not a password.
- Godot 4: the
press5_playaddon (GDScript,WebSocketPeer), same API:await Press5Play.connect_play({"key": KEY}). - Unity: the
com.press5.playpackage (C#,ClientWebSocket; WebGL builds use the browser's WebSocket). - Anything else: the protocol is plain JSON over WebSocket at
wss://play.press5.xyz/v1. Send{"t":"hello","v":1,"key":"p5g_..."}, then{"t":"quick"},{"t":"set","me":{...}},{"t":"send","data":...}. Full reference: https://my.press5.xyz/docs/multiplayer/protocol
Secrets and fair scoring in relay games
Guard limits numbers and rates; it cannot keep a secret. In a relay room:
- Everything in
room.stateand every player's state reaches every player (and anyone reading the network). Never put a secret there: the word to draw, the right answer, other players' cards. - Send a secret to one player only:
room.send({ type: 'word', word }, drawerId)(or a list of ids). - Scores belong to the host: award them in
room.state(guard them under"room"), never let each player write their own score insetMyState. - Let players check the host: at the start the host shares a hash of the secret plus a random salt; at the end it reveals both, and every page checks the hash. Then a host can't change the word mid-round.
- The host is still trusted to judge fairly. When that matters (hidden cards, quiz answers, competitive results), use a server engine instead:
turns(card-table keeps hands on the server) orparty(answers never leave it;"mode": "draw"is a whole drawing and guessing game with the word kept on press5). - Messages are capped at 40 a second per player: batch frequent things (send a stroke's points every 33 ms, not every mouse move).
Limits (free for now)
Up to 64 players a room, 300 players online per game (100 for unclaimed sites), 40 messages and 32 KB a second per player, 16 KB per message, 64 KB room state, 8 KB state per player, 64 KB for press5.game.json. Rooms close when everyone has left. press5 Play runs no code from games: only its own engines. Messages are relayed, not stored or logged. Server rooms: up to 100 a game (10 before the site is claimed), and press5 can block a game that abuses the service.
Checking on a game
game_info { site } (MCP, no sign-in) or GET https://my.press5.xyz/api/v1/play/sites/{name}: players online, rooms, manifest problems. Public numbers for any game: GET https://play.press5.xyz/v1/games/{name}. The arcade's list: GET https://play.press5.xyz/v1/games.