docs / getting-started / installation

Installation

g2w is a set of small npm packages composed at the application boundary. The fastest path is the create-g2w CLI, which scaffolds a complete TypeScript + Vite game project from a bundled template.

Requirements

Node.js ≥ 22 and a package manager. Every g2w package is ESM-only withNodeNext resolution, and the scaffolded project uses Vite for dev serving and bundling. pnpm is recommended but npm, yarn, and bun all work.

Scaffold with create-g2w

The CLI never prompts and runs no shell commands; its only subprocess is a local git init in the generated directory (skipped when Git is missing or the destination already has Git metadata).

shell
# scaffold a new game project (after the npm release lands)
pnpm create g2w my-game

cd my-game
pnpm install
pnpm dev

The generated project ships with a playable scene — a square you steer with WASD or the arrow keys — wired through G2WGame, aSceneManager, and a unit-tested movement module:

project structure
my-game/
├── index.html            # #game canvas + #error box
├── package.json          # dev / build / test scripts
├── tsconfig.json
├── src/
│   ├── main.ts           # composition root
│   └── scenes/
│       └── play-scene.ts # pure game logic
└── test/
    └── play-scene.test.ts # deterministic, no browser

Manual setup

Prefer to wire things yourself? Install the packages you need and followYour First Game:

shell
pnpm add @g2w/core @g2w/runtime @g2w/renderer-pixi @g2w/input-dom
pnpm add pixi.js # renderer-pixi peer: PixiJS 8

@g2w/core is the only package with zero runtime dependencies.@g2w/renderer-pixi adapts PixiJS 8 to the renderer contract, and@g2w/runtime adds the Effect-based G2WGamelifecycle. Add @g2w/input-gamepad for gamepads,@g2w/audio-web for sound, and @g2w/devtools for the read-only dev overlay.

Honest status

StatusThe @g2w/* packages are not published to npm yet. Until the release lands (Roadmap R10), pnpm create g2w resolves only from packed tarballs. Clone themonorepo, build, and pack the packages yourself:
shell
# from the monorepo root: build + pack every @g2w/* package
pnpm build
pnpm --filter "./packages/*" pack

Next steps

Head to Your First Game to walk through the scaffolded project line by line, or read thearchitecture notes for the boundary rules behind the package split.