How does netcode work for browser games?
Updated 2026-11-23
Short answer: netcode is how a multiplayer game keeps every player's screen close enough to the same game despite network delay. Browser games mostly use one of three models: state sync (one device or server owns the world and sends changes), lockstep (only inputs travel and every device runs the same deterministic simulation), and parallel rounds (everyone plays their own copy of the same seeded round and only scores or positions travel). On top of those, prediction and smoothing hide the delay. Which one you need depends on the genre, not the engine.
The problem: everyone sees the past
A message between two players takes time: often 20–80 ms between friends on one continent, and 150–250 ms across oceans, plus jitter on mobile networks. So whatever you receive about another player is already old. Netcode decides three things:
- Who is right when two devices disagree (authority).
- What travels: the whole state, changes, inputs, or just a score.
- How to draw the others between updates (prediction and smoothing).
Model 1: state sync
One device, the host (or a server), runs the real game. It sends the state, or what changed, to everyone else many times a second. Other players send their inputs or intents to the host.
- Good for: board, card and puzzle games, co-op builders, clickers, drawing games, casual arenas.
- Costs: bandwidth grows with the size of the world; non-host players feel about one round trip of delay on their own actions.
- Watch out for: merging. If two players score at once, sending "score = 11" from both loses a point. Sending "add 1" from both keeps it.
Joinable's shared world (Pattern A) diffs your existing state object 20 times a second, sends number changes as amounts to add, and matches array items by id. Avatars (Pattern B) send each player's input to the host, which moves everyone. Guides: board and card games, .io and arena games.
Model 2: deterministic lockstep
Only the players' commands travel. Every device runs the identical simulation from the same seed, one fixed tick at a time, applying the same commands on the same tick. Classic RTS netplay works this way.
- Good for: RTS, tower defence, auto-battlers: anything with too much state to send.
- Costs: a small input delay (orders run a few hundred milliseconds after the click, so they reach everyone first), and a simulation that must be perfectly deterministic.
- Watch out for: anything that differs between devices.
Math.random()outside a seeded generator, reading the clock, iterating a Set in network order, and maths functions such asMath.sin,atan2andhypot, which Chrome and Safari can round differently in the last digit. Lockstep systems compare a fingerprint of the state to catch drift.
In our own test, Firestorm, a real RTS, went out of sync between Chrome and Safari at tick 2412 because of exactly those maths functions. After the fix, a 4 v 4 battle ran 10,160 ticks with 0 differences. Guide: strategy games.
Model 3: parallel rounds
Each device runs its own copy of the game. Joinable gives them the same seed and the same start moment, and only a small summary travels: a score twice a second, or a car's position and velocity 20 times a second.
- Good for: racers, time trials, arcade, puzzle and party games: anything that ends with a score or a time.
- Costs: almost nothing. Your own game runs locally with no delay.
- Watch out for: randomness. Everything that changes the round must come from the seed.
Joinable calls these full rounds (race and score profiles), and recommends them whenever they fit: they don't touch your game's state. Guides: racing games, score games.
Prediction and smoothing
Between updates, a game has to draw other players somewhere.
- Interpolation draws them slightly in the past, between two known positions. Smooth, but always a little behind: in a racer, the car you see is not where the car is.
- Extrapolation (dead reckoning) moves them on from their last update by their velocity, to where they should be now. Joinable's
raceprofile does this along the turn the car was making, because racing cars nearly always are, and uses the sender's own timestamp so their network jitter doesn't skew the guess. - Smoothing eases a predicted object onto each new update over a short time (about 120 ms in Joinable's race profile) instead of snapping.
- Client-side prediction lets your own character move at once, before the server agrees. Joinable's race and score profiles get this for free, because your device owns your car or your round. In shared-world avatars, guests feel about one round trip today.
The rule we learned on Turbo Rally: draw and collide with the same estimate. The first version drew rivals 100 ms in the past but collided with a prediction of "now", so cars bumped into rivals that weren't where they appeared.
Rollback, and what isn't covered here
Rollback netcode (GGPO-style) predicts the other player's input, runs ahead, and rewinds and re-simulates when the real input arrives. It's what fighting games use. Joinable doesn't offer it. Neither does it offer a server running the game with lag compensation, which competitive shooters need.
Which model fits your genre
| Your game | Model | With Joinable |
|---|---|---|
| Racer, time trial, kart game | Parallel rounds, predicted rivals | race profile |
| Arcade, puzzle, runner, party mini games | Parallel rounds, live scores | score profile |
| Board, card, word, puzzle on one board | State sync, plus a turn check | Pattern A (+ C for turns) |
| Platformer, top-down, casual arena | State sync, host-authoritative input | Pattern B |
| RTS, tower defence, auto-battler | Deterministic lockstep | lockstep profile |
| Fighting game | Rollback | Not built |
| Competitive shooter | Server-authoritative, lag compensation | Not built |
To try any of these without writing a server, paste the prompt into your coding agent: it reads the kit, picks the model for your genre, and runs the self-test.
FAQ
What is netcode in games?
The code and the model that keep a multiplayer game consistent across players despite network delay: who is authoritative, what is sent, how often, and how other players are drawn between updates.
What's the difference between state sync and lockstep?
State sync sends the game's state, or its changes, from one authority to everyone. Lockstep sends only players' inputs, and every device runs the same deterministic simulation. Lockstep uses far less bandwidth for big worlds, but the simulation must give identical results on every device.
What netcode should a browser racing game use?
Each player owns their car, sends its position and velocity about 20 times a second, and draws rivals predicted to the present with smoothing. Bumps are shared: each device moves only its own car, by half.
Does Joinable support rollback netcode?
No. Joinable offers parallel rounds, shared-world sync and lockstep. Rollback for fighting games isn't built, and we don't recommend Joinable for them today.