Skip to content
A scroll, a wizard's hat, and seven illustrated hex tiles arranged around the words "Declarative Hex Worlds"

declarative-hex-worlds

Declarative, deterministic hex worlds for TypeScript games. Bootstrap KayKit assets in one command. First-class React + Three.js bindings.

Declarative API

Describe what you want — a harbor with three depth tiers, a procedural forest, a road network connecting both. The library handles tile selection, connectivity, prop scatter, and validation. No imperative grid bookkeeping.

Deterministic by construction

Same seed, same output — byte-identical, across processes and platforms. Server-authoritative simulation, save-game replays, and cross-machine reproducibility all work out of the box.

First-class React + Three.js

Not optional peer-deps. The library tests against the versions it ships and exposes idiomatic hooks and scene helpers. Install one package and start rendering.

  1. Install the package

    Terminal window
    pnpm add declarative-hex-worlds
  2. Fetch the FREE KayKit asset pack (CC0-licensed; ~30 MB)

    Terminal window
    pnpm exec declarative-hex-worlds bootstrap

    Downloads 221 GLTF models into public/assets/models/addons/kaykit_medieval_hexagon_pack/. SHA-256 sidecar verified.

  3. Render your first harbor

    import { Canvas } from '@react-three/fiber';
    import * as HexWorld from 'declarative-hex-worlds';
    const plan = HexWorld.createGameboardBuilder({
    seed: 'harbor-village-1',
    shape: { kind: 'rectangle', width: 6, height: 6 },
    }).build();
    const runtime = HexWorld.createGameboardRuntimeFromScenario({
    plan,
    scenario: { actors: [], quests: [] },
    });
    export function Harbor() {
    return (
    <HexWorld.GameboardProvider runtime={runtime}>
    <Canvas>{/* your three.js scene of rt.snapshot() */}</Canvas>
    </HexWorld.GameboardProvider>
    );
    }

Hex-grid games are simple in concept and a maintenance nightmare in code. Tile adjacency rules, biome blending, asset selection, deterministic seeding, multiplayer-safe replay — each is a small problem; all of them together is a six-month detour from shipping a game.

declarative-hex-worlds treats the whole stack as one declarative pipeline: recipe → blueprint → scenario → koota ECS world → React + Three.js render. You declare what you want and what’s allowed; the library decides what goes where, validates it, and gives you back a deterministic snapshot.

The hex-tile assets are the KayKit Medieval Hexagon Pack by Kay Lousberg — gorgeous, low-poly, CC0. The library bootstraps them at install time; the npm tarball stays small (~2.3 MB) and asset licensing stays clean.