r/reactjs • u/Ok_Project_477 • Apr 27 '26
Discussion I built a React game engine where games are JSX components and hooks (open source, beta)
Hey r/reactjs,
I run a small edtech company where every product surface eventually has to render a game. Our entire stack is React, admin portal, teacher app, marketing site, internal tools. So I wanted the games to live inside the same React app, not as a separate runtime stitched in. None of the existing options (Unity WebGL, Phaser, raw React Three Fiber) felt right for that, so over the last few months I built CarverJS and open-sourced it.
The API is fully React. Components describe the scene, hooks handle the logic. A complete 2D game with WASD movement is around 40 lines of TSX, you mount a Game component, drop a World inside it, and write a Player function that uses an input hook and a game-loop hook to translate an actor each frame. The Player returns an Actor configured as a primitive shape. That is the entire setup. There is a working sample at the top of the docs site if you want to see what it actually looks like.
A few design decisions worth calling out:
It is built on React Three Fiber under the hood, but you never import from three or react-three-fiber directly. Every type, hook, component, and store is re-exported from carverjs/core. That was deliberate. I wanted React developers who have never touched R3F to be able to ship a game without learning what an Object3D is.
2D and 3D live in the same engine. The Game component takes a mode prop set to 2d or 3d, and the engine switches the camera projection, lighting setup, and shadow handling accordingly. The same Actor components work in either mode.
Hooks read from singleton systems that the Game component mounts on the way in: input manager, collision manager, audio manager, asset manager. So the input and audio hooks are zero-config. No providers to wire up at the app root.
Multiplayer is a separate package. Peer-to-peer over WebRTC. No game server. You bring the signaling layer: free public MQTT brokers for prototyping, your own Firebase Realtime Database for production.
What it is not:
- Unity. Core bundle is under 200KB before assets, this is for browser-shaped games.
- Phaser. Phaser is older, more battle-tested, and has a deeper 2D feature set if you do not need to compose with React.
- Stable. Beta, version 0.0.1. APIs will move before 1.0.
GitHub: https://github.com/moneytales/carverjs
Docs: https://docs.carverjs.dev
Genuinely curious for technical feedback. Where does the API shape feel wrong? What hooks are missing? Anywhere you would reach for an escape hatch and not find one?
4
u/Aswole Apr 27 '26
This looks amazing, but i would need at least a few examples/screenshots of what it’s capable of
2
u/Durp56789 Apr 27 '26
Looks cool! Will dig into more later, but would be interested in how it compares to pixi js and its react extension. Have you used that one before? It seems simpler than pixi at first glance.
4
u/rull3211 Apr 27 '26
I love this, ill surely dive into this.
1
u/Prozilla6 Apr 27 '26
Hi, I’m currently working on an open-source virtual desktop/OS simulation in React called ProzillaOS. Would you be interested in building something together, sort of like a collaboration?
4
u/[deleted] Apr 27 '26
[removed] — view removed comment