Installation
Install Phaser 4 via npm or a CDN, and verify the install with a one-line scene.
From npm
# npm
npm install phaser
# bun
bun add phaser
Phaser 4 ships its own TypeScript types — no @types/phaser needed.
From a CDN
For quick experiments or single-file demos:
<script src="https://cdn.jsdelivr.net/npm/phaser@4/dist/phaser.min.js"></script>
@4 tracks the latest 4.x release. Pin to an exact version (e.g. phaser@4.1.0) in production so a new release can’t shift your behavior. See the changelog for current releases.
Verifying the install
The smallest possible Phaser 4 program — a black canvas, ready to receive game objects:
import Phaser from 'phaser';
new Phaser.Game({
type: Phaser.AUTO,
width: 400,
height: 300,
scene: { create() { this.add.text(10, 10, 'Phaser 4 is alive'); } },
});
If you see the text on a black background, you’re set up. Continue to Your First Scene.