Home
Getting Started

game-session

Session modes, run and progress recording, a pause flag, a React hook and pause-menu UI for browser games.

game-session is the small layer a browser game needs around its gameplay: a difficulty posture the player picked, somewhere to keep progress between visits, and a pause menu that stops the world without losing it.

It is split into three entry points so a game can take one without the others:

Entry pointContentsDependencies
game-sessionSession modes, run results, progress and save-slot shaping, the pause flagnone
game-session/reactlocalStorage functions and the useGameRuntime hookreact
game-session/uiPause menu, settings panel, error boundaryreact, lucide-react, Tailwind CSS

Why use it?

Problemgame-session convention
Every game invents its own easy/normal/hard constantsThree session modes with shared tuning to read
Progress in localStorage breaks when the shape changesEvery read is normalized; corrupt data degrades to defaults
A render loop needs to know the game is pausedA module-level flag plus a window event, no React subscription
"Continue" needs somewhere to keep a half-finished runOne active save slot per game, cleared when the run ends
Recording a result twice on a re-renderA recorder that dedupes by content

Start with Getting started, then use the API reference and the architecture notes.