{"id":28581763,"url":"https://github.com/dustinlacewell/react-ecs","last_synced_at":"2025-06-11T04:43:17.337Z","repository":{"id":37904280,"uuid":"355320748","full_name":"dustinlacewell/react-ecs","owner":"dustinlacewell","description":"An entity-component-system for React","archived":false,"fork":false,"pushed_at":"2023-06-18T18:40:46.000Z","size":12109,"stargazers_count":127,"open_issues_count":7,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-03T02:14:56.935Z","etag":null,"topics":["ecs","entity-component","react","react-ecs"],"latest_commit_sha":null,"homepage":"https://react-ecs.ldlework.com/","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/dustinlacewell.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T20:25:50.000Z","updated_at":"2025-06-02T20:05:15.000Z","dependencies_parsed_at":"2024-10-30T00:22:40.227Z","dependency_job_id":null,"html_url":"https://github.com/dustinlacewell/react-ecs","commit_stats":{"total_commits":7,"total_committers":4,"mean_commits":1.75,"dds":0.4285714285714286,"last_synced_commit":"9aac9f1e1e825e24b3d41131510fb37e6e331845"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinlacewell%2Freact-ecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinlacewell%2Freact-ecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinlacewell%2Freact-ecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinlacewell%2Freact-ecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dustinlacewell","download_url":"https://codeload.github.com/dustinlacewell/react-ecs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dustinlacewell%2Freact-ecs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259202003,"owners_count":22820937,"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","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":["ecs","entity-component","react","react-ecs"],"created_at":"2025-06-11T04:43:15.072Z","updated_at":"2025-06-11T04:43:17.324Z","avatar_url":"https://github.com/dustinlacewell.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/idle"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://react-ecs.ldlework.com\"\u003e\u003cimg src=\"https://i.imgur.com/Rn6yLZs.gif\" alt=\"React ECS\" width=\"300\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n  React ECS\n  \u003cbr\u003e\n  \u003ca href=\"https://react-ecs.ldlework.com\"\u003ereact-ecs.ldlework.com\u003c/a\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA declarative Entity Component System for React.\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://react-ecs.ldlework.com/docs/\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label\u0026message=Documentation\u0026color=grey\" alt=\"Documentation Link\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://react-ecs.ldlework.com/api/core\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label\u0026message=API\u0026color=grey\" alt=\"API Link\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://react-ecs.ldlework.com/examples/\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label\u0026message=Examples\u0026color=grey\" alt=\"Examples Link\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://react-ecs.ldlework.com/blog/\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label\u0026message=Blog\u0026color=grey\" alt=\"Blog Link\"/\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@react-ecs/core\"\u003e\n        \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/@react-ecs/core?color=green\u0026label=%40react-ecs%2Fcore\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@react-ecs/three\"\u003e\n        \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/@react-ecs/three?color=green\u0026label=%40react-ecs%2Fthree\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@react-ecs/boids\"\u003e\n        \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/@react-ecs/boids?color=green\u0026label=%40react-ecs%2Fboids\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://discord.gg/RJqjqAnmJ8\"\u003e\n        \u003cimg src=\"https://img.shields.io/discord/733027681184251937.svg?style=flat\u0026label=Join%20Community\u0026color=7289DA\" alt=\"Join Community Badge\"/\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://buymeacoffee.com/idle\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Support%20React%20ECS\u0026logo=buy-me-a-coffee\u0026color=blue\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nAn **ECS**, or _Entity Component System_ is a design pattern popular in simulations, visualizations and game-development. It eschews rich objects and complex inheritence hierarchies.\n\nInstead:\n\n-   **Entities**: A simple bag of facets.\n-   **Facets**: Simple data-only objects.\n-   **Queries**: Track entities which have specific facets.\n-   **Systems**: Process the facets of entities matched by queries.\n\n[React ECS](https://react-ecs.ldlework.com/) helps you build your simulations and games using this pattern, in standard React JS fashion (hooks, components, etc)\n\n\u003cbr\u003e\n\n# What does it look like?\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n        Let's make a simple simulation that updates a cube based on a \u003ccode\u003eSpinning\u003c/code\u003e facet, using React ECS' \u003ca href=\"https://threejs.org/\"\u003eThreeJS\u003c/a\u003e integration \u003ca href=\"https://react-ecs.ldlework.com/docs/three\"\u003e@react-ecs/three\u003c/a\u003e. \u0026nbsp; \u003csub\u003e\u003ca href=\"https://codesandbox.io/s/react-ecs-demo-tv5xj?from-embed=\u0026file=/src/index.tsx\"\u003e\n        \u003cimg src=\"https://img.shields.io/static/v1?label=\u0026message=Try%20it%20live\" /\u003e\u003c/sub\u003e\n    \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://codesandbox.io/s/react-ecs-nextjs-test-hp9do\"\u003e\n        \u003cimg src=\"https://i.imgur.com/hUgweKX.gif\" /\u003e\n      \u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## First define a Facet\n\nThis facet just tracks how much its entity should spin.\n\n```tsx\nclass Spin extends Facet\u003cSpin\u003e {\n    amount? = new Vector3(1, 1, 1);\n}\n```\n\n## Then define a System\n\nSystems use queries to track the entities they work upon.\n\nThis system uses a query to find entities with both the `ThreeView` and `Spin` facets. `ThreeView` is facet provided by [@react-ecs/three](https://react-ecs.ldlework.com/docs/three) to visually display entities in a [ThreeJS](https://threejs.org/) scene.\n\nThis system updates the entity's 3D rotation based on the `Spin` facet:\n\n```tsx\nconst SpinSystem = () =\u003e {\n    const query = useQuery((e) =\u003e e.hasAll(ThreeView, Spin));\n\n    return useSystem((dt) =\u003e {\n        query.loop([ThreeView, Spin], (e, [view, spin]) =\u003e {\n            const rot = view.object3d.rotation;\n            rot.x += spin.amount.x * dt;\n            rot.y += spin.amount.y * dt;\n            rot.z += spin.amount.z * dt;\n        });\n    });\n};\n```\n\n## Now put it all together\n\nNow we can create a component to tie it all together. For more information see our [documentation](https://react-ecs.ldlework.com/docs/) and [examples](https://react-ecs.ldlework.com/examples/).\n\n```tsx\nconst CoolSim = () =\u003e {\n  const ECS = useECS()\n  useAnimationFrame(ECS.update)\n\n  return (\n    \u003cCanvas\u003e\n      \u003cECS.Provider\u003e\n        \u003cSpinSystem /\u003e\n        \u003cEntity\u003e\n          \u003cSpin /\u003e\n          \u003cThreeView\u003e\n            \u003cBox /\u003e\n          \u003c/ThreeView\u003e\n        \u003c/Entity\u003e\n      \u003c/ECS.Provider\u003e\n    \u003c/Canvas\u003e\n  )\n}\n```\n\n[![Edit React ECS Demo](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-ecs-demo-tv5xj?fontsize=14\u0026hidenavigation=1\u0026theme=dark)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinlacewell%2Freact-ecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdustinlacewell%2Freact-ecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdustinlacewell%2Freact-ecs/lists"}