{"id":14963948,"url":"https://github.com/remarkablegames/phaser-jsx","last_synced_at":"2026-04-11T23:14:01.015Z","repository":{"id":216045849,"uuid":"740334192","full_name":"remarkablegames/phaser-jsx","owner":"remarkablegames","description":"📝 Use JSX in Phaser","archived":false,"fork":false,"pushed_at":"2025-09-26T02:12:29.000Z","size":3163,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T04:12:32.088Z","etag":null,"topics":["game","javascript","jsx","library","npm","package","phaser","phaser3","react","typescript","ui"],"latest_commit_sha":null,"homepage":"http://remarkablegames.org/phaser-jsx/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remarkablegames.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-08T06:07:42.000Z","updated_at":"2025-09-26T02:11:13.000Z","dependencies_parsed_at":"2024-11-11T03:27:01.935Z","dependency_job_id":"0ce3be7a-90a2-42d9-8ab0-50854383adc6","html_url":"https://github.com/remarkablegames/phaser-jsx","commit_stats":{"total_commits":426,"total_committers":4,"mean_commits":106.5,"dds":"0.26525821596244137","last_synced_commit":"f31e19702f84bff8c4f84b606bde06ce77300e54"},"previous_names":["remarkablegames/phaser-jsx"],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/remarkablegames/phaser-jsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablegames%2Fphaser-jsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablegames%2Fphaser-jsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablegames%2Fphaser-jsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablegames%2Fphaser-jsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkablegames","download_url":"https://codeload.github.com/remarkablegames/phaser-jsx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablegames%2Fphaser-jsx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278335450,"owners_count":25970129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","javascript","jsx","library","npm","package","phaser","phaser3","react","typescript","ui"],"created_at":"2024-09-24T13:32:22.360Z","updated_at":"2026-04-11T23:14:01.009Z","avatar_url":"https://github.com/remarkablegames.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phaser-jsx\n\n[![NPM](https://nodei.co/npm/phaser-jsx.png)](https://nodei.co/npm/phaser-jsx/)\n\n[![NPM version](https://img.shields.io/npm/v/phaser-jsx.svg)](https://www.npmjs.com/package/phaser-jsx)\n[![build](https://github.com/remarkablegames/phaser-jsx/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablegames/phaser-jsx/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/remarkablegames/phaser-jsx/graph/badge.svg?token=EZEOFDL9ME)](https://codecov.io/gh/remarkablegames/phaser-jsx)\n\n📝 Use [JSX](https://facebook.github.io/jsx/) in [Phaser](https://phaser.io/).\n\n### Examples\n\n- [CodeSandbox](https://codesandbox.io/p/devbox/phaser-jsx-9ldp6n)\n- [JSFiddle](https://jsfiddle.net/remarkablemark/dLhvuo42/)\n- [Examples](https://github.com/remarkablegames/phaser-jsx/tree/master/examples)\n\n## Quick Start\n\nWith JSX:\n\n```tsx\n// index.jsx\nimport Phaser from 'phaser';\nimport { Text, render } from 'phaser-jsx';\n\nnew Phaser.Game({\n  scene: {\n    create() {\n      render(\u003cText text=\"Hello, world!\" /\u003e, this);\n    },\n  },\n});\n```\n\nWithout JSX:\n\n```ts\n// index.js\nimport Phaser from 'phaser';\nimport { jsx, render } from 'phaser-jsx';\n\nnew Phaser.Game({\n  scene: {\n    create() {\n      render(jsx(Phaser.GameObjects.Text, { text: 'Hello, world!' }), this);\n    },\n  },\n});\n```\n\n## Install\n\n[NPM](https://www.npmjs.com/package/phaser-jsx):\n\n```sh\nnpm install phaser-jsx\n```\n\n[Yarn](https://yarnpkg.com/package/phaser-jsx):\n\n```sh\nyarn add phaser-jsx\n```\n\n[CDN](https://unpkg.com/browse/phaser-jsx/):\n\n```html\n\u003cscript src=\"https://unpkg.com/phaser@latest/dist/phaser.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/phaser-jsx@latest/umd/phaser-jsx.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nES Modules:\n\n```ts\nimport { createElement, render } from 'phaser-jsx';\n```\n\nCommonJS:\n\n```ts\nconst { createElement, render } = require('phaser-jsx');\n```\n\nUMD:\n\n```html\n\u003cscript src=\"https://unpkg.com/phaser@latest/dist/phaser.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/phaser-jsx@latest/umd/phaser-jsx.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const { render, jsx } = window.PhaserJSX;\n\u003c/script\u003e\n```\n\n## TypeScript\n\nFor better type support, install [@types/react](https://www.npmjs.com/package/@types/react):\n\n```sh\nnpm install @types/react --save-dev\n```\n\nImport the [GameObject](https://docs.phaser.io/phaser/concepts/gameobjects) from `phaser-jsx` instead of `phaser`:\n\n```ts\nimport { Text } from 'phaser-jsx';\n```\n\n\u003e [!TIP]\n\u003e All GameObjects exported from `phaser-jsx` are aliases of the GameObjects from `phaser`.\n\nUpdate your `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"jsx\": \"react-jsx\",\n    \"jsxImportSource\": \"phaser-jsx\"\n  }\n}\n```\n\n## Vite\n\nUpdate your Vite config:\n\n```ts\n// vite.config.mjs\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  esbuild: {\n    jsxImportSource: 'phaser-jsx',\n  },\n});\n```\n\n### JSX Pragma\n\nIf you're not using `jsxImportSource`, you can set a JSX pragma at the top of your file:\n\n```tsx\n/** @jsx jsx */\nimport { jsx } from 'phaser-jsx';\n```\n\n## How Does It Work?\n\nThis package follows [React](https://react.dev/) conventions like having `createElement` and `jsx-runtime`.\n\nThe `render` function renders game objects inside a scene.\n\nIf you need nesting and relative positioning, use `Container`:\n\n```tsx\n\u003cContainer\u003e\n  \u003cText text=\"Child 1\" /\u003e\n  \u003cText text=\"Child 2\" /\u003e\n\u003c/Container\u003e\n```\n\n## Hooks\n\n### `useRef`\n\nCreate a ref for your game object:\n\n```ts\nimport { useRef } from 'phaser-jsx';\n\nfunction MyComponent() {\n  const textRef = useRef\u003cPhaser.GameObjects.Text\u003e();\n  // ...\n}\n```\n\nPass your ref to the JSX element:\n\n```tsx\n// ...\nreturn \u003cText ref={textRef} onPointerDown={handleClick} /\u003e;\n```\n\nAccess your game object:\n\n```ts\nfunction handleClick() {\n  textRef.current?.text = 'Clicked';\n}\n```\n\nAlternatively, you can get the game object with a callback ref:\n\n```tsx\n\u003cText\n  ref={(gameObject) =\u003e {\n    gameObject.text = 'Hello, world!';\n  }}\n/\u003e\n```\n\n### `useScene`\n\nRetrieve the current Scene with the `useScene` hook:\n\n```ts\nimport { useScene } from 'phaser-jsx';\n\nfunction MyComponent() {\n  const scene = useScene();\n  // ...\n}\n```\n\n\u003e [!WARNING]\n\u003e Don't use the `useScene` hook if you start multiple Scenes.\n\nType your Scene with TypeScript:\n\n```ts\nclass MyScene extends Phaser.Scene {\n  // ...\n}\n\nconst scene = useScene\u003cMyScene\u003e();\n```\n\n## Release\n\nRelease is automated with [Release Please](https://github.com/googleapis/release-please).\n\n## License\n\n[MIT](https://github.com/remarkablegames/phaser-jsx/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablegames%2Fphaser-jsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkablegames%2Fphaser-jsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablegames%2Fphaser-jsx/lists"}