Easy Multiplayer

Powerful rollback multiplayer without a game server or game-specific networking code.

Build Your First Game Try the Example
Current documentation: v0.4 The public API is EasyMultiplayer.performanceMode. Start with a schemaless deterministic game, then add schemas or advanced runtime controls only when your game needs them.

A Complete Multiplayer Loop

export function createGame() {
  return {
    initialState: () => ({ players: {} }),
    queries: {
      join: input => input?.join === true,
      axis: inputs =>
        Number(inputs[0]?.right === true) - Number(inputs[0]?.left === true),
    },
    step(ctx) {
      ctx.discoverParticipants('join', 4);
      for (const id of ctx.participants()) {
        const player = ctx.state.players[id] ??= { x: 0 };
        player.x += ctx.query(id, null, 'axis');
      }
    },
  };
}

Connect that module to a room, sample local controls, and render session.getMirror().state. EM handles peer discovery, worker simulations, input prediction, rollback, correction, and convergence.

Why Input Queries?

Queries describe the game decision that depends on input, rather than exposing an undifferentiated input stream. When late input changes raw controls but not the queried decision, EM can avoid rolling back that tick.

Start Schemaless

Use normal plain objects. Add a schema later only if profiling justifies it.

Peer to Peer

Share a room URL. No authoritative application server is required.

Rollback Aware

Prediction and correction happen behind a small deterministic game API.

Advanced When Needed

Control schemas, input delay, presentation, workers, and transports.

Start Here