Typed end to end
Action inputs and views are inferred from your game, all the way to useTable() in React. No
code generation.
These are the rules of tic-tac-toe, from the
example in the repository
(winnerOf is a plain function in the same file). Input is checked against the schema,
out-of-turn moves are rejected, and a rejected action changes nothing.
export const ticTacToe = defineGame({ id: 'tic-tac-toe', name: 'Tic Tac Toe', seats: { min: 2, max: 2 },
setup: () => ({ board: Array<Mark | null>(9).fill(null), winner: null as Mark | 'draw' | null, }),
turns: { order: 'round-robin' },
actions: { place: { input: z.object({ cell: z.number().int().min(0).max(8) }), run({ state, seat, input, ctx }) { if (ctx.turn.seat !== seat) reject('NOT_YOUR_TURN'); if (state.board[input.cell]) reject('CELL_TAKEN'); state.board[input.cell] = seat === 0 ? 'X' : 'O'; state.winner = winnerOf(state.board); if (state.winner) ctx.end({ winner: state.winner }); else ctx.turn.next(); }, }, },});Host it, and any number of tables can be played at once:
import { createServer } from 'shoehive/server';
await createServer({ games: [ticTacToe] }).listen({ port: 3000 });Typed end to end
Action inputs and views are inferred from your game, all the way to useTable() in React. No
code generation.
Hidden information
Clients only ever receive what your view() lets each seat see. Hole cards stay hidden.
Turns and rounds
Turn-based games, and round-based play where everyone acts at once against a timer.
Reconnects and restarts
Guest sessions with resume tokens. Tables survive a server restart with SQLite, Postgres or Redis.
Deterministic
Seeded randomness and a recorded action log power tests, replays and time travel in the devtools.
Test without sockets
createTestTable(game) runs your rules in a unit test with a fake clock.