Declarative Phaser3 + UI renderer core library
npm install @number10/phaserjsx> Declarative Phaser3 UI framework with React-like components and TypeScript
A modern, type-safe framework for building game UIs in Phaser3 using JSX components, hooks, and a powerful theme system.


- ๐จ React-like API - Familiar JSX syntax with hooks (useState, useEffect, useMemo, etc.)
- ๐ฏ Type-Safe - Full TypeScript support with strict type checking
- ๐จ Powerful Theme System - Global and component-level theming with runtime switching
- ๐ฆ Rich Component Library - Button, Text, Icon, Accordion, Dropdown, CharTextInput, and more
- ๐ญ Built-in Effects - 23+ animation effects (pulse, shake, fade, bounce, etc.)
- ๐ฑ Responsive Design - Flexible layout with multiple size value formats (px, %, vw/vh, fill, auto, calc)
- ๐ง Custom Components - Easy to create and integrate custom components
- ๐ฎ Phaser Integration - Seamless integration with Phaser3 game objects and scenes
- ๐ SVG Support - Convert SVG to Phaser textures with caching
- ๐ Performance - Optimized VDOM reconciliation with smart dirty checking
``bash`
npm install @number10/phaserjsx phaseror
yarn add @number10/phaserjsx phaseror
pnpm add @number10/phaserjsx phaser
`json`
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@number10/phaserjsx"
}
}
`tsx
import { useState, View, Button, Text } from '@number10/phaserjsx'
function Counter() {
const [count, setCount] = useState(0)
return (
} fontSize={32} color={0xffffff} />
)
}
`
`tsx
import * as Phaser from 'phaser'
import { mountJSX } from '@number10/phaserjsx'
class GameScene extends Phaser.Scene {
create() {
mountJSX(this, Counter, {
width: this.scale.width,
height: this.scale.height,
})
}
}
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: [GameScene],
}
new Phaser.Game(config)
`
๐ฎ Live Examples on StackBlitz
See usage examples below for quick reference.
`tsx
import { useState, View, CharTextInput, Button, Text } from '@number10/phaserjsx'
function LoginForm() {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const handleLogin = () => {
console.log('Login:', username, password)
}
return (
onChange={setUsername}
placeholder="Username"
maxLength={20}
/>
onChange={setPassword}
placeholder="Password"
isPassword
maxLength={20}
/>
)
}
`
`tsx
import { View, Button, Text } from '@number10/phaserjsx'
import type { Theme } from '@number10/phaserjsx'
const customTheme: Theme = {
Button: {
backgroundColor: 0x4caf50,
cornerRadius: 8,
padding: { x: 24, y: 12 },
Text: {
fontSize: 18,
color: 0xffffff,
},
},
}
function ThemedButton() {
return (
)
}
`
`tsx
import { Button, Text } from '@number10/phaserjsx'
function AnimatedButton() {
return (
effect="pulse"
effectConfig={{ intensity: 1.1, time: 800, repeat: -1, yoyo: true }}
onPress={() => console.log('Pressed')}
>
)
}
`
Generate custom icon components from SVG files:
`bashGenerate icon components
npx generate-icons
Configuration in
icon-generator.config.ts:`typescript
import type { IconGeneratorConfig } from '@number10/phaserjsx/scripts/icon-generator-config'export default {
inputDir: './src/assets/icons',
outputFile: './src/custom-icons/generated-icons.tsx',
typesFile: './src/custom-icons/icon-types.ts',
componentName: 'CustomIcon',
defaultSize: 24,
} satisfies IconGeneratorConfig
`๐จ Vite Plugin
Automatic icon generation during development:
`typescript
import { defineConfig } from 'vite'
import { phaserjsxIconsPlugin } from '@number10/phaserjsx/vite-plugin-icons'export default defineConfig({
plugins: [
phaserjsxIconsPlugin({
inputDir: './src/assets/icons',
outputFile: './src/custom-icons/generated-icons.tsx',
}),
],
})
``Contributions are welcome! Please visit the main repository for contribution guidelines.
GPL-3.0-only. Commercial licensing availableโcontact Michael Rieck (Michael--) at mr@number10.de.
- ๐ Documentation
- GitHub Repository
- npm Package
- Issue Tracker