Module

Multiplayer

Authoritative, turn-based multiplayer sessions on Cloudflare. The server holds the game state no client can be trusted with, resolves it, and writes a durable result to your own D1.

@pithy-sh/multiplayer

Built for Games Mobile apps
terminal
pithy add multiplayer
Read the docs Source on GitHub

What it is for

The server holds the game state no client can be trusted with, resolves it, and writes a durable result you own.

The session is the same for every game; what a game is lives behind a game model, resolved by kind. Three ship as examples, and you can register your own.

What it sits on

Durable Objects, with the result written to your D1.

Pithy's first Durable Object. Adding it wires the DO binding and its class migration tag into wrangler.jsonc for every environment; a migration creates the result table.

A session holds hidden per-player state, an alarm-driven deadline, and a one-way publish to the leaderboard when it ends.

  • Durable Objects
  • D1

The honest bit

Turn-based, and that word is doing real work.

This is authoritative session infrastructure for games where a turn resolves discretely — board games, card games, wagering tables. It is not a tick-rate netcode layer for a shooter, and no amount of configuration turns it into one.

If you build it yourself

Authoritative state is easy to describe and hard to hold.

The rule is simple: never trust the client. Everything after that is the work.

One writer for the state

Two clients acting at once must serialize somewhere. A Durable Object is that somewhere, and it is why this is not a table.

Hidden per-player state

Each player sees their own hand, not everyone's. That has to be true on the server, not in the UI.

Deadlines and disconnects

A player who walks away must not stall the game, which means an alarm, a timeout policy and a defined result.

Reconnection

The same player returning to the same session, with the same view, after their phone slept.

A durable result

When it ends, something has to be written down — and published to a leaderboard exactly once.

terminal
pithy add multiplayer

In the dashboard

Administer it from a browser, without building the screen.

Live sessions, their membership, and the durable results they wrote.

The dashboard is the admin interface for your own application: whatever this capability writes, your team can look up, check and act on from a browser. Reading is free, forever, with no time limit. Connect the project when you deploy.

Designed, not shipped

What is coming to this capability.

Written down, argued out, and not built yet. Each one links to the issue it is being designed in, so you can read the reasoning or disagree with it.

Add it, and get on with the feature.

One command installs the package, wires its bindings into every environment your project declares, and runs its migrations.