Game
Your game's front end (the graphics, the input, the sound) is ordinary static code you can host anywhere (with Sitehoster, say). To make it multiplayer you drop in one JavaScript file: the client library your server generated for this exact game. It handles all the networking so you can concentrate on the gameplay.
It's generated per game
You don't install this library from a package manager. Each game's API endpoint serves its own
copy, built from that game's definition. Fetching it from the game's own
domain means the world model and the predict/ logic it carries always match the server
it's going to talk to.
# the library is served by the game's own endpoint (domain + game path)
https://game.example.com/pong/client.js
Drop it in
Import it and connect. connect() opens the WebSocket to the game's API and hands back a
handle to the room:
<script type="module">
import { connect } from 'https://game.example.com/pong/client.js'
// open the WebSocket API and join a room as a named player
const game = await connect({ room: 'lobby', name: 'Ada' })
// the authoritative state, kept in step for you; render it however you like
game.on('state', (state) => draw(state))
// who else is here, updated live
game.on('presence', (players) => showPlayerList(players))
// send inputs, not positions — the server is authoritative
window.addEventListener('keydown', (e) => {
if (e.key === 'ArrowUp') game.input({ move: 'up' })
if (e.key === 'ArrowDown') game.input({ move: 'down' })
})
// move this player into the match when the lobby is ready
game.join()
</script>
What the library does for you
Connection & rooms
Opens and keeps the WebSocket alive, joins an instance, and reconnects your session if the network blips.
State & presence
Delivers the authoritative state each tick and a live list of who's in the room, so your render loop just reads the latest values.
Prediction
Runs the game's predict/ logic locally so your own actions show instantly and
other players move smoothly between server updates.
Reconciliation
When the authoritative tick arrives it corrects the local guess for you. Because prediction and simulation come from one definition, those corrections stay small.
Next steps
The shape of the game (its rooms, state and the logic behind all this) is defined in the game folder.