Phaser Hooks Overview
React-like hooks for Phaser 3 game development with state management and lifecycle hooks.
Phaser Hooks
React-like hooks for Phaser 3 game development with state management and lifecycle hooks. Bring the power of React's component model to your Phaser games.
Key Features
đĒ
React-like Hooks
Familiar hooks API for state management and side effects
đ
Global State
Shared state management across scenes and components
đ
Local State
Component-level state management with automatic updates
âĄ
Lifecycle Hooks
useEffect, useUpdate, and other lifecycle management hooks
đ¯
TypeScript Support
Full TypeScript support with type-safe hooks
đ
Automatic Updates
Components automatically re-render when state changes
Available Hooks
Quick Start
import { useGame, useGlobalState, useLocalState } from 'phaser-hooks';
class MyScene extends Phaser.Scene {
create() {
// Use hooks in your scene
const game = useGame(this);
const [score, setScore] = useGlobalState('score', 0);
const [health, setHealth] = useLocalState(this, 'health', 100);
// State updates automatically trigger re-renders
setScore(score + 10);
setHealth(health - 5);
}
} Installation
npm install phaser-hooks Phaser Hooks brings React's powerful state management to Phaser 3, making your games more maintainable and easier to develop.