Keep the match moving
when the host leaves.

Build host-authoritative multiplayer with typed RPC, direct peer connections, and deterministic host migration in one open-source SDK.

game.ts
import { Dendri, Room }
  from "@afterrealism/dendri-client";

const options = { url: "wss://signal.example.com" };
const room = new Room("game-42", {
  migrationTimeout: 5000
});

room.join(Dendri, options);

room.on("hostChanged", (newHostId) => {
  if (room.peerId === newHostId) {
    becomeAuthority();
  }
});

Players remember the interruption.
Not your topology.

A good multiplayer loop makes the infrastructure disappear. Dendri handles the room transitions that would otherwise become your game code.

Every client has an opinion.

If every peer can rewrite shared state, the match becomes a disagreement with better graphics.

Intents in. State out.

Clients send moves through typed RPC. The current host validates each intent, applies it, and broadcasts the next authoritative state.

The host closes the tab.

The match should not end because the person who created it has to leave.

Another player takes over.

Deterministic election promotes a new host. Re-register your RPC methods on hostChanged and continue the game loop there.

The network blocks WebRTC.

A move that never arrives feels exactly like a broken game.

The move finds another route.

Dendri can fall back through STUN, TURN, and a TLS relay. Critical events can use acknowledgements to confirm delivery.

Build the loop, not the lobby plumbing.

One room owns discovery and authority. Your game owns the rules, the state, and what makes the next move fun.

Read the game walkthrough →
  1. Open the game room

    Join with your endpoint and a migration timeout that fits your game.

    const room = new Room("game-42", { migrationTimeout: 5000 });
    room.join(Dendri, { url });
  2. Validate intents on the host

    Register the moves your game accepts, then broadcast the resulting state.

    room.registerRpcMethod("move", validateAndApplyMove);
    room.broadcast(state, { topic: "state" });
  3. Move authority with the host

    When election finishes, the new host registers the game handlers.

    room.on("hostChanged", (newHostId) => {
      if (room.peerId === newHostId) becomeAuthority();
    });

Close the host. Keep playing.

Open the game in two tabs, then close the first one and watch authority move.

The host is a peer.
Not a dedicated game server.

Dendri fits peer-hosted rooms, with up to 50 data peers by default. If you need central anti-cheat, large persistent worlds, or authority that lives outside every player's browser, keep a dedicated game server in the architecture.

Give the next match a longer life.

Start with one room and make the first move together.