@caisual/kit
v0.25.0
Published
Client and server kit for Caisual games
Maintainers
Readme
@caisual/kit
The game kit for Caisual, a free home for small browser games with multiplayer built in.
The kit gives a published game a stable player identity, cloud saves, a daily challenge seed, rooms with server-owned state, voice, matchmaking, and friends. It is one JavaScript module with no dependencies and never touches the page: the game fills the window and draws its own menu, lobby and results.
Client
npm install @caisual/kitimport { caisual } from '@caisual/kit';
const c = await caisual.connect();
console.log(c.player.name, c.player.language);
const room = await c.room.create({ mode: null });
room.onState((state) => draw(state));
room.ready(true);A published game can also load the same module from its own origin, without a bundler: import { caisual } from '/__caisual/kit/v1.js?v=0.25.0'.
Server
server.js beside the manifest owns the room. It runs without Node.js APIs or network access.
import { defineGame } from '@caisual/kit/server';
export default defineGame({
tickRate: 0,
onMessage(room, player, message) {
room.broadcast(message);
},
});Documentation
- Kit reference: every call, event and limit.
- Publishing guide: the folder, the manifest and the CLI.
- Guides: rooms, voice, matchmaking, friends, saves, versions, limits.
- llms.txt: the index of every guide for coding agents.
Publish with @caisual/cli. Publishing is free; games run on caisual.com.
Instant matchmaking
Enable a mode with "matchmaking": true, then call await c.room.match({ mode: 'arena' }). It enters a room immediately. room.origin is matchmaking; player-created rooms use player and always have a lobby.
Matchmaking has no ready button or setup choices. The server assigns roles and teams. Below players.min, draw waiting as a playable practice scene with a short notice. At the minimum, the room starts a three-second countdown. Players can join during countdown and play up to players.max. Normal rounds restart automatically after eight seconds. The local dev server follows these same rules.
