Open source · TypeScript

Interactive fiction for any shape of game

Everything you'd build in Twine, written in TypeScript instead: typed content, saves that survive updates, a checker that catches mistakes before players do, and a UI that looks like your game, not the engine's.

IFLoom is in early development: until 1.0, names and shapes can change from one release to the next. What's stable

cafe.ts
import type { Content } from '@ifloom/engine'

export const cafe: Content = {
  stats: [
    { id: 'coins', label: 'Coins', start: 3,
      format: '£{n}', spendable: true },
  ],
  scenes: [{
    id: 'counter',
    title: 'The Corner Café',
    body: [{ text: 'counter' }],
    choices: [
      { id: 'tea',
        effects: [{ stat: 'coins', by: -2 }] },
      { id: 'cake',
        effects: [{ stat: 'coins', by: -5 }],
        blocked: [{
          when: { stat: 'coins', lt: 5 },
          reason: 'You only have £3 on you.',
        }] },
    ],
  }],
  prose: {
    counter: 'A lemon cake sits under a glass dome.',
    'counter#tea': 'A pot of tea',
    'counter#cake': 'A slice of lemon cake',
  },
}
What the engine's view says to draw

The Corner Café

Coins £3

A lemon cake sits under a glass dome.

A pot of tea£2
A slice of lemon cake£5You only have £3 on you.

Start a game

UI
Start
Theme
npm create ifloom@latest my-game -- --theme paper

It makes a new game in my-game. Then cd my-game, npm install and npm run dev. With no --template it starts from react, the React UI; the choices above pick another. There’s also next, a Next.js app, and plugin, a plugin package: Create a game covers every template and option.

What you get

A small core, and the rest when you need it

01

Write the game you want

A short novel, a business you run week by week, a town full of people with their own days. Scenes, stats and characters are yours to shape, and the engine doesn't assume a genre.

A life simA calendar, places, a cast with their own days, and a phone.
examples/showcase/src/world/cast.tsSource
export const people: Content = {
  storylines: [{ id: 'ava', name: 'Ava' }],
  entities: [
    cast.person({
      id: 'ava',
      name: 'Ava',
      fullName: 'Ava Marsh',
      description: 'Runs the café',
      image: 'art/character/ava.svg',
      // The React UI colours her lines with this hue.
      ui: { hue: 20 },
      home: 'park',
      // At the counter through the working day.
      schedule: [{ location: 'cafe', when: { all: [
        calendar.weekday(0, 1, 2, 3, 4, 5),
        calendar.period('morning', 'afternoon')] } }],
      // By the river, once she is a friend.
      talk: [
        { scene: 'ava.river', when: { all: [places.at('park'),
          { stat: 'friendship', of: '$', gte: 25 }] } },
        { scene: 'ava.hi' },
      ],
      storyline: 'ava',
      call: { scene: 'ava.call',
        when: calendar.period('evening', 'night') },
    }),
  ],
}

Each one is an example game in the repository, and a template for ifloom new.

02

Plugins

Add what your game needs and leave out the rest. Plugins work together when a game has both, but never depend on each other.

World
Progress
Phone
Tools
03

Your look, your framework

The engine is a library with no UI. It gives your UI a view: what to show and what each button does. Draw it with React, Vue, Svelte or plain DOM. Or take the ready-made React UI and restyle any part with plain CSS, swap its classes, start unstyled, or replace any component, down to the page itself. Nothing gives away which engine the game runs on.

[data-part="choice"] { border-radius: 0; font-family: "Your Font";}
ReactVueSvelteplain DOMHow the pieces fit
04

Tools that catch it before players do

Your content is typed, so your editor autocompletes ids and kv a typo as you make it. The rest is a command away.

  • ifloom devReloads the game as you write.
  • ifloom checkFinds broken links, missing pictures and sounds, and misspelt ids.
  • ifloom playtestPlays a week on its own and writes down every screen.
  • ifloom snapshotRenders every scene and shows what changed since the last run.
  • debug pluginJumps to any state while you test, without playing up to it.
05

Ship one file

ifloom build makes one index.html that opens straight from disk, with your pictures, sounds and videos beside it. Put it on itch.io, your own site, or a USB stick.

Add --inline-assets and the pictures go inside the page too, so a game without video or sound is that one file and nothing else.

dist/index.html
06

Sound, video and pictures you can click

Music, ambience and voice lines play on their own channels and crossfade between scenes. Videos sit inline in the prose, and pictures can have hotspots the player clicks.

[[video:]][[sound:]]hotspots
07

Works with your coding agent

Every new game comes with an AGENTS.md that tells an agent where the docs are and how to check its work. The docs are published as llms.txt, and an MCP server lets an agent search them.

llms.txtifloom.dev/api/mcpUsing an agent
Coming from Twine?

What you know from SugarCube, as data the checker reads

Passages become scenes and links become choices, and the macros you use most have a direct counterpart. Twine stays the quicker start for a short story; IFLoom is for when it grows into a game with systems.

ToSugarCubeIFLoom
Change a variable<<set $coins -= 3>>{ stat: 'coins', by: -3 }
Show a line only sometimes<<if $coins gte 3>>when: { stat: 'coins', gte: 3 }
Go to a passage[[Leave|Street]]{ id: 'leave', label: 'Leave', effects: [{ scene: 'street' }] }

Start with the tutorial

Go from an empty project to a finished short story in an afternoon, then build from there.

Coming from SugarCube or Harlowe?