Learn

WebSockets vs WebRTC for browser multiplayer games

Updated 2026-11-23

Short answer: WebSockets are a reliable, ordered connection from a browser to a server. They're simple, work on every network, and are what most browser multiplayer games use. WebRTC data channels connect browsers to each other and can be unordered and unreliable, like UDP, which cuts latency for fast action games, but they need signalling, STUN and often a TURN relay, and much more code. For racers, score games, board games, casual arenas and lockstep strategy, a WebSocket to a nearby server is enough. Joinable uses exactly that: one WebSocket per player to a room on Cloudflare's network.

WebSockets in one minute

A WebSocket starts as an HTTP request and becomes a two-way, long-lived connection between the browser and a server.

WebRTC data channels in one minute

WebRTC is the browser's peer-to-peer stack, built for video calls. Its data channels carry game messages directly between players.

Side by side

WebSocket to a serverWebRTC data channel
DeliveryReliable, orderedReliable or not, ordered or not: your choice
PathPlayer → server → playerDirect when possible, else via TURN
Servers you needOneSignalling, STUN, TURN
Works on strict networksYesOnly through TURN
Code in the browserSmallLarge: connection setup, candidates, renegotiation
Late joiners, saved stateThe server has themSomeone has to keep them
Best forMost browser gamesFast 1 v 1 action, voice and video

Does the hop matter?

Less than people expect: the distance between the players dominates. Friends on one continent typically see 20–80 ms to a room near the first player; across oceans, 150–250 ms. Direct WebRTC helps most when two players are close to each other but far from any server.

And netcode hides most of it. A racer predicts rivals to the present, a score game sends only scores, a lockstep RTS runs orders a few hundred milliseconds later on purpose. Where the transport really decides the feel is precise 1 v 1 action: fighting games with rollback, and twitchy shooters.

What Joinable uses, and why

Joinable's SDK opens one WebSocket per player to the room: messages are JSON, and if the connection drops it reconnects with backoff (from half a second, doubling to at most 10 seconds, with jitter) and resends what was queued. The room is a Cloudflare Durable Object, created near the first player and holding every player's WebSocket with Cloudflare's hibernation API, so an idle room costs nothing between messages.

Why a WebSocket and not WebRTC:

<script async src="https://relay.getjoinable.com/sdk.js" data-connect="invite"></script>

Where WebRTC could come in

Peer-to-peer data channels, with the relay as matchmaker and fallback, are on our roadmap for fast action and for very large games. We estimate that about 10–20% of players would still need a TURN relay, which costs about as much as our relay does. Not built yet: we'll say so here when it is.

Which should you use?

FAQ

Is WebRTC faster than WebSockets for games?

It can be, for fast action: unreliable channels skip lost packets instead of waiting, and a direct link skips the server hop. For most browser games the difference is small next to the distance between players, and netcode hides it.

Do WebSockets work for real-time multiplayer games?

Yes. Most browser multiplayer games use them: racers, board games, casual arenas, strategy. They're reliable, work on every network, and a nearby server keeps latency low.

Does WebRTC need a server?

Yes. A signalling server to set up the connection, STUN to find public addresses, and a TURN server that relays all traffic for players whose networks block direct links.

What does Joinable use?

One WebSocket per player to a room on Cloudflare's network (a Durable Object created near the first player). Your game's code never opens it; the SDK does, and reconnects on its own.

Copy the prompt for your coding agent or sign up free