# How to make a multiplayer browser game with no server

> How to make a multiplayer browser game with no server: rooms, invite links, a host-run match and direct links, from two open-source games, with prompts.

Built by @rehan_shei, @nicholaskkao.
Published 2026-11-24 on https://patch.gg/blog/multiplayer-browser-game-no-server

The usual way to make a multiplayer browser game is to write a Node.js server, hold a WebSocket open to every player and host the server somewhere that never sleeps. You can skip all of that. On Patch, a browser game gets rooms with 6-character codes, invite links, quick match and direct links between players from `window.patch`, and Patch runs the servers. The game keeps its own rules: one player hosts what everyone shares, and every screen sends its state 10 to 20 times a second.

This guide shows how, from the netcode of two open-source games made on Patch the week [Patch Multiplayer](https://x.com/patch_gg/status/2125017669623787877) launched: [spellyard](https://patch.gg/games/rehan/spellyard), a 1v1 to 3v3 wizard brawler by @rehan_shei, and the online co-op in [Siege](https://patch.gg/play/nick/siege), a voxel zombie shooter for up to 4 by @nicholaskkao. Each step gives the real numbers both games use, with two prompts along the way you can hand your coding agent.

You should know how your game's loop runs. You don't need to know any networking.

![Six wizards in two teams trade fire and lightning on spellyard's floating island](https://cdn.patch.gg/media/sha256/a7/ab/a7ab4136d3941b9ea95322fb20741f93eae2a62e4003241cb6b26e05fc9792a1#clip "spellyard online, 3v3 (from @rehan_shei's post)")

## What you need

- **A browser game** in any engine or none. spellyard is plain JavaScript, drawn with pixelfx. Siege is TypeScript on three.js with WebGPU, built with Vite.
- **A coding agent** that can run Patch's CLI, `pch`, or use its MCP server at patch.gg/api/mcp. Siege's commits name Claude Fable 5.2 as co-author.
- **A Patch account.** Only players signed in to Patch get direct links (step 5).
- **Two browser profiles**, each signed in to its own Patch account, to test direct links.
- **No server.** Patch's docs say of rooms: "There's no server to run and nothing to declare." Direct links are the same: "nothing to run, declare or pay for."

## 1. Give your agent Patch's guide

Install `pch` and connect your agent with `pch agent install`. Then have the agent run `pch guide` (or call `guide` first over the MCP server), which is Patch's own guide to making, testing and publishing a game.

The fastest start is someone else's working netcode. Both games are open source under their makers' handles, so `pch clone rehan/spellyard` or `pch clone nick/siege` gives your agent the whole thing to read, and `pch remix` makes a project of your own from one. As @BlendiByl [put it](https://x.com/BlendiByl/status/2125018703557468652) on launch day: all the games in the launch video "are open-source, including all multiplayer logic"

Before your agent changes any code, ask it to clone both into a scratch folder, read their networking files (spellyard's `src/net.js`, Siege's `src/net.ts` and the Co-op section of its `AGENTS.md`) and then your game, and give you a short plan: what each player's screen should send, what one host should run for everyone, and what goes in the room's data.

You should get back a plan in three lists. If your agent can't say what goes in each, read the two networking files with it before going on.

## 2. Get players into a room

A room is the players in a game together. Patch keeps who's in it, who hosts it and its data, and passes their messages on. Getting in is three calls, tried in this order:
1. **An invite link first.** `patch.getLaunch()` gives the room of the invite link the game was opened from, or the room the tab was in before a reload. Both games check it at start and, if there is one, join it.
2. **Play online** is `patch.rooms.quickMatch`: it joins the fullest listed room with space and the same player limit, or makes one. spellyard asks for 6 players and keeps an empty room for 5 minutes; Siege asks for 4. Patch's docs add that the host's `room.setListed(false)` takes a room off quick matches once a match starts.
3. **Play with friends** is `patch.rooms.create` with `listed: false`, so strangers never land in it. spellyard keeps that room 10 minutes after the last player leaves.

To bring friends in, `room.invite()` gives `{ link, copied }`: Patch copies the invite link for the player, and the game says so. spellyard has an invite board in its yard that toasts "invite link copied"; Siege's lobby has an Invite friends button, and I opens it in a town.

Rooms take 1 to 100 players (8 by default), and an empty room waits 2 minutes by default, up to 1,440 (a day).

Plan for the calls failing, in the player's words. Siege turns each error code into a line: `room_full` is "That town is full (4 players).", `room_not_found` is "That town isn't there any more.", and `room_needs_update`, which means the player's page is on an older version than the room's, is "Reload the page to get the newest version, then join again."

And keep the game playable alone. `window.patch` is only there when the game plays on Patch. spellyard's answer: offline, you host a room of one and nothing is sent, so the rest of the game never asks whether it's online.

What you should see: the room's 6-character code on screen (spellyard shows "yard Q8XIT4" and the player count in the corner), and a second player arriving in the same code from your invite link. Testing that needs a test link (step 11).

![Siege in first person: the crew shoots zombies through a voxel town as walls break apart](https://cdn.patch.gg/media/sha256/67/b7/67b7a6f5f362d29f2f0040b722678883baaefb2d294507f7cb2caafd7c945c27#clip "Siege co-op (from @nicholaskkao's post)")

## 3. Decide who decides what

Before any message is sent, decide which screen owns each thing in the game. Patch passes messages on; it doesn't run your rules. So every rule needs one screen whose word counts, or two players will see two different games.

Patch picks a host for you: the first player in, and when the host leaves, or its page has been hidden for 5 seconds, whoever has been in the room longest and is still on screen. Patch's docs say to "let the host run what everyone shares, such as the world, the clock or the bots." Both games do, and both give each player their own character:

|                   | spellyard                                     | Siege                                               |
| ----------------- | --------------------------------------------- | --------------------------------------------------- |
| The host runs     | The match (phase, teams, score), and the bots | The zombies, the rounds, and everything that breaks |
| Each screen runs  | Its own wizard                                | Its own body and guns                               |
| Someone else runs | The tower's monsters, by the climb's lead     | Nothing: the others ask the host to break things    |

![Two columns: in spellyard the host runs the match and bots and each screen its own wizard; in Siege the host runs zombies, rounds and destruction and each screen its own player](https://cdn.patch.gg/media/sha256/a7/3a/a73a05748a7daea6a1eddb5edaccb02f4251894abd4615699f0fe00bcb66d1db "Who decides what, in each game")

Siege is the stricter of the two, because its town has to break the same way on every screen. A player's screen never breaks the town itself: it asks the host, and the host breaks it and tells everyone. Only the loose rubble falls by each player's own physics. Hits on zombies are decided on the shooter's screen.

The prompt in step 4 asks your agent for this split along with the network layer.

## 4. Send state 10 to 20 times a second, under the 30 limit

Each player may send at most 30 messages a second through the room, with bursts of 60, and setting the room's data counts too. Past that, the message is dropped and the sender gets a `too_fast` error. Patch's docs suggest sending state 10 to 20 times a second and smoothing it on the other screens.

The trick both games use is to send one message per tick, with everything in it, instead of one message per event:
- **spellyard** ticks 20 times a second. Each tick is one message: the wizard's state, the host's bots, and every event since the last tick. The player's profile goes once a second. Its own limit is a bucket of 40 messages, refilled at 24 a second, and on a `too_fast` it backs off for 1.5 seconds.
- **Siege** queues events and flushes through the room every 66 ms, about 15 times a second, packing as many events into each message as fit in 13,000 characters. It allows itself 22 messages a second with bursts of 36, well under Patch's 30 and 60. For state, only the newest counts: a newer position replaces an older one still waiting.

Mind the size too: a room message carries up to 16 KB of JSON. Siege, which sends what broke in the town, packs it small and sends each voxel by its place (which object, which cell), never by its number, because the floor reuses voxel numbers.

```prompt
Write my game's network layer over window.patch.rooms, with one owner for everything shared. The room's host (room.isHost) runs the enemies, the round and anything that changes the world, and sends the results; every other screen asks the host instead of changing the world itself. Each player's screen runs only its own character and sends its state. Add a single isAuthority(thing) check and use it everywhere the game changes shared state. When the host changes (the room's host event), the new host carries on from the room's data.

Queue events (in order) and keep only the newest of each kind of state (my player's position, the host's enemies). Every 50 ms, send it all through room.send as one message, split only if it passes 13,000 characters of JSON. Keep a token bucket of 36 that refills at 22 a second, counting room.setData as a send, so we never reach Patch's 30 a second. On a too_fast error, send nothing for 1.5 seconds. Then test it with pch check.

If pch (Patch's CLI) isn't installed, install it with curl -fsSL https://patch.gg/install.sh | sh (on Windows, in PowerShell: irm https://patch.gg/install.ps1 | iex), then run pch login. Read the rooms section of pch guide before you start.
```

What you should see: no `too_fast` errors in the console with every player moving and fighting at once.

## 5. Switch state to direct links when they open

Room messages arrive in order. For positions that's more than you need: a position from 200 ms ago is worth nothing once a newer one exists. Direct links give you the choice. `room.link(id)` opens a link to another player through Patch's relay. A link message arrives, in order, by default; with `reliable: false` it goes at once or not at all, in no order, which is what Patch's docs suggest for state. Players never see each other's addresses. Only players signed in to Patch get links.

![Animation: three players send batched messages through the room, then direct links open between them and positions go straight across while events still arrive in order](https://cdn.patch.gg/media/sha256/90/93/9093dcde61786b587418dba8058662f39c8df3513ac18339ad0fc24532ad0cdc#clip "Before links, the room carries everything. After, state goes over the links and events keep their order")

Both games treat links as an upgrade, never a requirement:
- **spellyard** opens a link to each player as they join. Once every other player is linked, its ticks go over the links: the state with `reliable: false`, and the events in a second message with `reliable: true`, which arrives, in order. Until then, everything stays in the room.
- **Siege** sends state over links up to 30 times a second. Each pair links once, from the player whose id sorts first, so two links never open at once. It tries 3 times per player, 8 seconds apart, and relinks 8 seconds after a link closes. Anyone not linked yet still gets state through the room, and the host's zombies go 10 times a second through the room, 20 once every player is linked.

If `room.link` fails with `no_direct_links`, the player isn't signed in or isn't on Patch. Siege stops asking and lets the room carry everything, as it always could.

Ask your agent to add direct links to your network layer the same way: the player whose id sorts first opens each link, state goes over every open link up to 30 times a second with `reliable: false`, and events stay in the room. On `link_failed` it retries up to 3 times, 8 seconds apart, and on `no_direct_links` it stops trying, so anyone without a link keeps getting state through the room.

## 6. Draw the other players a little in the past

State that arrives 20 times a second looks like stutter if you draw it as it lands. The usual fix (Gabriel Gambetta's [entity interpolation](https://www.gabrielgambetta.com/entity-interpolation.html) explains it): draw the other players slightly behind, between two updates you already have.

spellyard's numbers:
- Each update carries the wizard's position, velocity, aim, facing, animation, health, meter and a few flags, stamped with `room.now()`, the room's clock, which reads the same on every screen.
- Each screen keeps the last 30 updates per wizard and draws them 100 ms behind the room's clock, between the two updates either side of that moment.
- When no newer update has come, it carries the wizard on at its last velocity, for 0.15 seconds at most.
- When the drawn wizard is more than 60 pixels from where it should be, it jumps there instead of sliding across the island. Smaller gaps it eases out every frame.

Your own character never waits: it moves the moment you press a key, because your screen owns it (step 3).

What you should see, at the test link in two profiles: the other player walks and turns smoothly, about a tenth of a second behind their own screen, and never slides across the map after a hiccup.

## 7. Keep the match in the room's data

The room's data is one JSON object, up to about 16 KB, that only the host can set with `room.setData`. Every player gets it, and so does anyone who joins later. It's where the state of the match lives, so nobody's screen has to guess.

spellyard's match code says it in one line: "The host decides and writes it into the room's data; every screen follows that data." The host checks the match five times a second. Before a round, the match counts down for 3 seconds, and a round ends when one team has nobody left standing, or after 90 seconds, when the team with the most health wins. First to three rounds takes the match.

Siege's room data starts as a lobby. A room whose town hasn't started is its lobby: everyone waits there, invites friends and sees who's in, and the map is picked there. The host's Start writes the run (and the map) into the room's data, and every screen goes in. A newcomer to a room whose town is already going is taken straight in, mid-round.

## 8. Catch up whoever joins late

A room message reaches only the players in the room when it's sent. A player who joins late gets the room's data and nothing else, so the host has to send them what they missed, to them alone with `room.send(message, { to: player.id })`.

Siege does it as a short handshake. The newcomer sends `hello` to the host. The host answers with the wave, the phase, whether the power is on and the drops on the ground, then everything that has broken in the town so far, squeezed with the browser's own deflate compression and cut into pieces of 11,000 characters. The newcomer rebuilds the town from it in one go.

spellyard needs less: the yard, the teams and the match are in the room's data already, and each wizard's next tick says where it is.

If your world changes as it's played, ask your agent for Siege's handshake: the newcomer sends `hello` to the host alone, and the host answers to them alone with the round, the score and everything that has changed in the world since the start. That last part goes compressed with `CompressionStream('deflate-raw')` and cut into numbered pieces under 11,000 characters, and the newcomer rebuilds the world once every piece has arrived.

What you should see: a player who joins a minute in sees the same broken walls, score and round as everyone else.

## 9. Survive drops, reloads and host changes

Players close tabs, lose Wi-Fi and reload. The rules that kept both games together:
- **A dropped connection rejoins.** When the room closes with `lost`, spellyard shows "connection lost, rejoining..." and joins the same code again. A player who reloads comes back as the same player.
- **A silent player is away.** spellyard treats a player it hasn't heard from in 4 seconds as away, and the match skips them, so one frozen tab can't stall a round.
- **Old messages from an earlier match are dropped.** Every Siege message carries the run it belongs to. When the host starts the town again, messages from the last run are thrown away, except the few about getting into step.
- **The host can change.** Patch moves the host when it leaves or hides its page for 5 seconds. The room's data stays, which is one more reason to keep the match there.

## 10. Test several players on one machine

Real rooms need real accounts. For everything else, both games fake Patch on one machine:
- **spellyard's `src/mockpatch.js`** stands in for `window.patch` across browser tabs, with a delay of 40 ms each way, up to 10 ms of jitter and 2% of unreliable link messages lost unless the page's address says otherwise (`?lag=`, `?jitter=`, `?loss=`, `?nolinks=1`). It copies Patch's limits (30 a second, bursts of 60, 16 KB), so a game that sends too much fails on the mock first. `tools/mp-test.mjs` plays the game in several pages of one Chrome at once and saves screenshots of every page side by side.
- **Siege's `scripts/coop.mjs`** plays three players in one browser against its own `scripts/mock-patch.js`, lobby first, and runs 48 checks. Its mock has no links, so it tests the room alone.

```prompt
Write a stand-in for window.patch.rooms for my game's tests, like spellyard's src/mockpatch.js (pch clone rehan/spellyard): rooms shared across tabs over BroadcastChannel, a host, room data, room.send with Patch's limits (30 a second, bursts of 60, 16 KB, too_fast past that), and room.link with 40 ms of delay, 10 ms of jitter and 2% loss, or no_direct_links with ?nolinks=1. Then write a Playwright script that opens 3 pages on one room, plays for 60 seconds and fails on any page error. When it passes, run pch publish and give me the test link.
```

What you should see: three pages in step with each other on the mock, then two real profiles in one room at the test link.

## 11. Test with real accounts on a test link

Direct links need the real thing. Publish with `pch publish`, which answers with a test link: the game's play page with `?release=`, which plays that version on Patch, sign-in and rooms included, before your players get it. In the first browser profile, open the test link, start a room and copy its invite link. Open that invite link in a second profile, signed in to a second Patch account.

Siege adds `&patch-test=1` to the invite link in each profile, which turns on its self-checks: each page logs `pass linked` once its direct link opens. Opened with no invite, `?patch-test=1` is how Patch's own test starts a game, alone, so with it and no room the game must play solo.

## The result

spellyard's commits run from November 22 to 23, 2026, to version 0.1.4: a wizard brawler for 1v1 to 3v3 with 31 spells in five slots, and a co-op climb up three floors of a tower to the cinder king. Siege's co-op brought up to four players into one town, with a lobby, new weapons and a rule for going down: a downed player bleeds out after 30 seconds unless a teammate holds E for 3 seconds to revive them. Neither game has a server of its own.

@nicholaskkao's [post](https://x.com/nicholaskkao/status/2125069134769902033) says new maps and matchmaking are coming to Siege next.

## Common questions

### Do I need a server to make a multiplayer browser game?

Not on Patch. Rooms, room data, the shared clock, invite links, quick match and direct links come from `window.patch`, and Patch runs the servers. A game whose rules no player's browser should decide can still bring its own server and check who's playing with a player token from Patch.

### Can players cheat if their browser decides hits?

Some can, and that's the trade both games make for a game that feels instant. spellyard trusts each screen about its own wizard; Siege trusts the shooter. For a casual co-op or party game that's the usual choice. For competitive play, keep the rules that matter on the host, or on your own server.

### How many players can a room hold?

A room takes 1 to 100 players. spellyard caps its rooms at 6 and Siege at 4, which keeps every player's messages, and each screen's work drawing everyone else, small.

### WebSockets or WebRTC for a browser game?

On Patch you don't wire either up yourself. Room messages arrive in order, which suits events and the match. Direct links can send a message at once or not at all, which suits positions, and both games move state to links when they open. An engine with its own WebRTC code can still use Patch's relay through `room.iceServers()`.

## Try it

- Play [spellyard](https://patch.gg/games/rehan/spellyard) and [Siege](https://patch.gg/play/nick/siege), then `pch clone` either one to read its netcode.
- Read Patch's [game backend docs](https://docs.patch.gg/game-backend) for every call and error code.
- More games made with a coding agent on the blog: a [weeping angel mechanic](/blog/weeping-angel-mechanic-threejs) in three.js, and [AI game VFX](/blog/ai-game-vfx-threejs) drawn from flipbooks.

## Credits

spellyard by @rehan_shei, drawn with pixelfx. Siege by @nicholaskkao, built with three.js on WebGPU and Steven Bobyn's three-voxel-destruction and three-avbd, with Claude Fable 5.2. Patch Multiplayer by Patch (@patch_gg).

## Sources

- https://x.com/patch_gg/status/2125017669623787877
- https://x.com/rehan_shei/status/2125019050413813835
- https://x.com/nicholaskkao/status/2125069134769902033
- https://x.com/BlendiByl/status/2125018703557468652
- https://docs.patch.gg/game-backend
- https://docs.patch.gg/cli
- https://patch.gg/games/rehan/spellyard
- https://patch.gg/play/nick/siege
- https://www.gabrielgambetta.com/entity-interpolation.html
