Press5.xyz

press5 Play

Multiplayer for your game

Rooms, matchmaking and shared state for games on the launch pad. No server to write.

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

  1. Make the game as a static site (HTML, JS, canvas, Phaser, three.js, a Godot web export...).
  2. Load the SDK: <script src="https://play.press5.xyz/sdk/v1/press5-play.js"></script> (or import Press5Play from 'https://play.press5.xyz/sdk/v1/press5-play.mjs').
  3. 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);
}
  1. Optional: add press5.game.json next to index.html (see below).
  2. Deploy like any site (deploy_site, npx @press5/cli deploy, or POST 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.
  3. 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:

  1. 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 |

  1. Start from the template (get_template) instead of a blank page: it already connects, matches, reconnects and draws. Keep its press5-play.js next to index.html.
  2. Write press5.game.json with "$schema": "https://my.press5.xyz/schemas/press5.game.json" at the top, a title, maxPlayers, "listed": true, a thumbnail, and either the "server" block (settings: engine_reference) or, for a relay game, a "guard" block (format: guard_reference).
  3. Check it: check_game { manifest } (MCP) or POST https://my.press5.xyz/api/v1/play/check. Fix every error (each comes with its fix) and read the warnings. Repeat until ok is true.
  4. Deploy with deploy_site. The reply's multiplayer field repeats the check against the live file.
  5. Verify: game_info { site } shows players, rooms and anything press5 Play noticed (next says 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

{ "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));

How a relay room works

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

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
}
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; });

Patterns that work

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.

Secrets and fair scoring in relay games

Guard limits numbers and rates; it cannot keep a secret. In a relay room:

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.