Skip to content

Getting Started

Inspired by Twine SugarCube, Choicekit is a lightweight1, headless, framework-agnostic library for building interactive fiction.


  • Passages and navigation
  • State with snapshot-based history
  • Saving and loading with versioning, optional compression, and migrations
  • Deterministic pseudorandom number generation (PRNG)
  • Custom class serialization for richer game objects
  • Headless by design (you bring the renderer and UI)

Install from npm package choicekit.

Terminal window
npm install choicekit

Notes on the current API:

  • Prefer ChoicekitEngineBuilder for ergonomic type-safe setup
  • Passage content lives on passage.data
import { ChoicekitEngineBuilder } from "choicekit";
const engine = await new ChoicekitEngineBuilder()
.withName("test-story")
.withPassages(
{ name: "Start", data: "You wake up in a quiet room.", tags: ["intro"] },
{ name: "Hallway", data: "A long corridor stretches ahead." },
)
.withVars({ playerName: "Dave", inventory: { gold: 123, gems: 12 } })
.build();
engine.setVars((state) => {
state.playerName = "Sheep";
state.inventory.gems = 21;
});
engine.navigateTo("Hallway");
  1. Less than 8KB after minification and gzip compression