back to all projects

G2W — Game to Website2026

G2W — Game to Website

Project Summary

g2w (Game to Website) is an open-source, TypeScript-first framework for building and shipping HTML5 games — 2D first, 3D planned — for desktop and mobile web browsers. Instead of installing a multi-gigabyte engine, you run pnpm create g2w my-game and your game runs directly in the browser, TypeScript end to end. Live docs at g2w.alexanderar.com, source on GitHub, published to npm under the @g2w organization.

The Problem

Browser-game tooling sits at two extremes: all-in-one engines (Phaser) bundle everything and decide everything for you, while pure renderers (PixiJS) leave every architectural decision to you. Neither gives you a framework structure — game loop, scenes, input, audio, lifecycle, devtools — that survives changing the rendering technology underneath.

The Solution

g2w is the middle layer: a framework skeleton with a zero-dependency core where the renderer is not an implementation detail but a tested contract — the same conformance suite (12 features per backend) runs against WebGL, Canvas, and WebGPU backends in real headless browsers. Architecture rules are enforced by tests themselves: @g2w/core cannot depend on PixiJS, the DOM, or Effect, and an architecture test fails the build if that ever changes.

Key Features

  • Renderer-agnostic core — swap WebGL/Canvas/WebGPU backends behind one tested contract; core has zero runtime dependencies.
  • 8 npm packages — core, Effect-based runtime, Pixi renderer, DOM + gamepad input, web audio, devtools, and the create-g2w CLI scaffold.
  • 453/453 tests — architecture rules, lifecycle/disposal ownership, and cross-backend conformance all enforced in CI on every commit.
  • npm trusted publishing — OIDC-based release workflow with fail-safe version validation gates.
  • Live docs site — Astro documentation with Ctrl+K search, playground, benchmarks, and an honest roadmap, deployed to Cloudflare Pages via CI.
  • Real benchmarks — headless Chrome CDP harness, median-of-3: 60 fps up to 5,000 sprites; cross-framework comparison against raw PixiJS, Phaser 4, and Three.js on identical workloads.

Technologies Used

  • TypeScript (strict) — end to end, no un-justified any.
  • pnpm workspaces — monorepo for the 8-package ecosystem.
  • PixiJS 8 — first renderer backend (WebGL/Canvas/WebGPU).
  • Effect — application runtime lifecycle (G2WGame), kept out of the core.
  • Vitest — 453 tests including the architecture-enforcement suite.
  • Astro — documentation website with search and playground.
  • Cloudflare Pages — CI/CD deployment for the docs site.