Bash.tv → GitHub → itch.io

Choose and design how a browser game plays online or together. Decision guide for local co-op, turn-based, real-time server-authoritative, host-and-guests peer-to-peer and shared-state games; Bash spaces (rooms, shared values, routes from the playing-together guide) versus your own WebSocket server versus WebRTC; where to host a game server when the game ships to itch.io or other portals; messa...

Download skill (.zip) Files on GitHub

Multiplayer architecture

Decide how players are connected and who decides what is true before writing any networking code. Changing either later means rewriting most of the game.

First: is this a Bash space with a kit?

Bash kits (game-kit-2d, game-kit-3d, app-kit) already include rooms, shared saved values, room messages and server routes, with the viewer’s Bash name. Read the playing-together skill and use those. It handles hosting, sign-in, reconnects and “alone first”. Only build your own server (below) when:

Pick the model

Game Model Skills
Same screen, same room (couch play) Local co-op: no network local-coop
Quiz, party, voting, drawing, board game in rounds Shared state + server rules (Bash rooms and routes, or a small server) playing-together, multiplayer-lobbies
Turn-based (cards, chess, tactics) Server checks each move, sends the new state multiplayer-security, multiplayer-reconnection
Real-time action, 2-16 players, strangers Authoritative server: clients send inputs, the server simulates, sends snapshots websocket-multiplayer, network-synchronization, multiplayer-prediction
Real-time with friends, no server budget Host and guests (peer-to-peer): one browser runs the game webrtc-multiplayer
Talk while playing Voice over WebRTC beside any model voice-chat-integration
High scores, daily challenge No live connection: submit and fetch leaderboard-system, game-replay-system

Rules of thumb:

The authoritative loop (real-time)

client: read input → apply locally (prediction) → send { seq, input } 60x/s
server: apply each input with the SAME step function → tick world at 60 Hz → send snapshot 20x/s { tick, ents, ack: last seq }
client: own player = server state + replay inputs after ack (reconcile); others = drawn 100 ms in the past (interpolation)

Where it runs

Piece Where
The game page itch.io, GitHub Pages, Netlify, Cloudflare Pages (static files: see docs/services)
A WebSocket game server A host that runs Node all the time: Fly.io, Render, Railway, a small VPS. itch.io and the static hosts can’t run it
Signaling for WebRTC The same small server, or Bash room messages
Leaderboard A server route, Supabase (docs/services/supabase.md), or Bash routes in a kit

A server started in the Bash sandbox is reachable through its preview address, including WebSockets, which makes it good for building and testing with friends. Don’t treat it as permanent hosting.

From an itch.io page, the game connects with wss://your-server.example.com/ws (secure WebSockets are required on HTTPS pages). Allow that page’s origin on the server (origins option in game-server.mjs).

Build order

  1. Make the game fun offline with a bot or local second player. Networking amplifies whatever is there.
  2. Put the rules in shared/, pure functions with dt in seconds and no Math.random() (seeded RNG).
  3. Lobby (multiplayer-lobbies) and a match with 2 browsers on a perfect network.
  4. Add prediction and interpolation, then test on a bad network (game-network-testing has net-sim.js profiles).
  5. Reconnection, cheating checks, spectators and leaderboards.
  6. Alone first: one person can always start and play (a bot, or a solo mode). A game that waits for a second person looks broken.

Pitfalls

Trusting the client (positions, scores, hits), different movement code on client and server, sending every frame at full size, no protocol version, game logic inside network callbacks, testing only on localhost, and starting with 3D, 32 players or an MMO.

Tested

Run every module test in this category: node assets/tests/all-modules.mjs (94 checks across lobbies, matchmaking, security, sessions, sync, prediction, replays, leaderboards, spectators and local co-op). The server and voice tests live in websocket-multiplayer, leaderboard-system and webrtc-multiplayer.