Efe Anidi
Engines & rendering

Phaser

A mature open-source HTML5 framework for 2D games in JavaScript or TypeScript, with WebGL and Canvas rendering.

Best for
2D browser and mobile-web games
Pricing
Free (open source); paid editor and AI services available
Licence
MIT
Site
phaser.io ↗

What it is

Phaser is an open-source framework for making 2D games that run in the browser. Its README describes it as a “fast, free, and fun open source HTML5 game framework that offers WebGL and Canvas rendering across desktop and mobile web browsers”, and says it has been actively developed for over 13 years. You write games in JavaScript or TypeScript, and the framework handles the scene system, sprites, animation, tilemaps, input, sound, cameras, particles and physics.

The framework is MIT licensed and maintained commercially by Phaser Studio Inc together with its community. Phaser 4 is the current major version; the latest release at the time of writing is v4.2.1, released in July 2026. The company also sells products around the open-source core, including Phaser Editor, a visual editor for building scenes.

Games can ship on the web or as YouTube Playables, Discord Activities and Reddit games, and the project notes that you can compile to iOS, Android, Steam and native desktop using third-party wrappers.

Where it fits in AI game development

Phaser is the 2D counterpart to Three.js: the framework to ask an assistant to target when the idea is a platformer, a puzzle game, a top-down shooter or anything else that does not need a third dimension. It has a long history and a lot of public example code, so models generally know it well. Its scene-based structure (a class with preload, create and update methods) is also a pattern that generated code tends to follow cleanly.

Phaser Studio is leaning into this directly. The Phaser 4 site mentions “skills files” intended to be fed to AI coding agents such as Claude Code, Cursor and Codex, so they have better context on the API. At the time of writing, the phaser.io homepage itself leads with a hosted “Phaser Game Agent” that builds games from a text description, using what it calls a new, agent-oriented Phaser engine. That service is not evaluated here, and it is a separate product from the open-source framework this page is about. If you want to write or review the code yourself, the framework is still free and open source.

Where Phaser earns its place for AI-assisted work:

  • Quick 2D prototypes. One scene class and a config object gets you a playable test.
  • Pairing with generated art. Sprite sheets, tilesets and backgrounds from image tools drop straight into Phaser’s loader.
  • Games inside other platforms. Discord Activities and similar formats suit small, quick-to-build games.

Strengths

  • Focused on 2D. The API is designed around sprites, tilemaps and arcade-style physics, so you are not fighting a 3D engine to make a 2D game.
  • Mature and well known. Years of tutorials and examples mean both you and your AI assistant have plenty to draw on.
  • Easy start. An official CLI scaffolds projects with templates for bundlers like Vite and front-end frameworks such as React, Vue and Svelte.
  • Runs anywhere a browser does. Desktop, mobile web and the embedded platforms listed above.
  • MIT licence. No royalties or revenue thresholds.

Limits

  • 2D only. The open-source framework is a 2D tool. If your project might grow into 3D, start elsewhere.
  • Version confusion. Phaser 3 was current for a long time, and much of the material online, including what AI models learnt from, targets it. Phaser 4 is the current major version, and generated code may mix the two. Check the version you have installed and the migration notes when something fails.
  • Native builds need extra tools. Getting onto app stores or Steam means wrapping your game with something like Capacitor or Electron.
  • Commercial upsell. The core is free, but the company’s site now puts its paid products, including the AI agent, front and centre. That is fine, but it is worth knowing which part you are actually using.

Getting started

The quickest route is the official project generator:

npm create @phaserjs/game@latest

For first-time users, the Phaser docs suggest choosing “Web Bundler” and then “Vite”. If you would rather add it to an existing project:

npm install phaser

A minimal game with one scene looks like this:

import Phaser from 'phaser';

class Main extends Phaser.Scene {
  create() {
    this.add.text(400, 300, 'Hello, Phaser', { fontSize: '32px' })
      .setOrigin(0.5);
  }
}

new Phaser.Game({
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  scene: Main
});

Phaser.AUTO picks WebGL where available and falls back to Canvas. From here, the official examples and API documentation cover loading sprites, arcade physics and tilemaps. When prompting an assistant, state “Phaser 4” explicitly to cut down on outdated suggestions.

Verdict

Phaser is the default choice for 2D games in the browser. It is mature, free, well documented and familiar to AI coding tools, which makes it ideal for fast iteration. Be clear about which major version you are on, and treat the company’s hosted AI agent as a separate product to judge on its own merits.

More in Engines & rendering