Phaser 4 (RC-5), Next.js v16 App Router, React v.19 deprecates forwardRef, code cleanup, other fixes
Further iterating on this: https://github.com/phaserjs/template-nextjs/pull/3
Since these templates and requested features (https://github.com/phaserjs/template-nextjs/issues/5) are not a current priority at the moment for the very busy core team, I thought I would help out especially as the previous PR on this was helpful to others despite no merge. As mentioned in the previous PR, it is good to give back when the core team gives us so much.
Updates (from the previous update - see earlier PR #3 linked at the top):
- Uses Phaser 4
- Next.js 16
- Better code, cleaner app router, ships with latest Next.js (16) defaults
- Includes default prettier for ease of use with vscode
[!NOTE] Upgrade to Next.js 16, React 19, and Phaser 4 with App Router migration, refactored Phaser bridge/scenes, and revamped tooling (ESLint flat config, Prettier, Tailwind/PostCSS, scripts).
- Core Upgrades:
- Bump deps to
next@^16,react@^19,react-dom@^19,[email protected]; require Node>=24.- Replace
next.config.mjswith typednext.config.ts.- App Router Migration:
- Remove
src/pages/*; addsrc/app/layout.tsxandsrc/app/page.tsx.src/App.tsxmarked'use client'and loaded via App Router.- Phaser Integration Refactor:
- Introduce
src/game/scenes/common/GameScene.tsbase class; restructure loaders underscenes/loaders/*and centralizeCONFIG.- Rewrite
src/game/PhaserGame.tsx: dynamic import (no SSR), dropforwardRef, acceptrefprop andonChangeScenecallback; useEventBusto update scene ref.- Update scenes (
MainMenu,Game,GameOver) to extendGameSceneand emitcurrent-scene-readyviaeventBus.- Tooling & Config:
- Add flat ESLint config
eslint.config.mjs; remove.eslintrc.json.- Add Prettier (
.prettierrc).- Add Tailwind 4/PostCSS (
postcss.config.mjs), keep global styles.- Update scripts: add
start,lintand*-nologvariants; keeplog.js.- Update
.gitignore; addpnpm-lock.yaml; removepackage-lock.json.- Docs:
- Refresh
README.mdto reflect App Router structure and commands.Written by Cursor Bugbot for commit 2e4a3dfbf1833c0e3f22d3848a6f2a16fbcce9ae. This will update automatically on new commits. Configure here.