mujoco-react
mujoco-react is a composable React Three Fiber wrapper around mujoco-js. It provides components for loading models, stepping physics, and rendering bodies. Controllers like IK are opt-in plugins.Composable
<IkGizmo />, <Debug />, <ContactMarkers /> etc. are R3F children you add to your scene.Controller Pattern
Controllers are React components that call
useBeforePhysicsStep. Write your own or use the built-in ones.Pluggable IK
Swap in any IK solver via
ikSolveFn, or skip useIkController entirely and solve IK yourself in useBeforePhysicsStep.Full MuJoCo
Contacts, sensors, tendons, flex bodies, raycasting, domain randomization. The full MuJoCo API via React hooks.
Quick Start
Controllers
A controller is a React component that callsuseBeforePhysicsStep to write data.ctrl each frame:
<MujocoCanvas>:
useIkController() hook follows this same pattern. You can also plug in your own IK solver or skip it entirely.
Design Philosophy
mujoco-react follows the same pattern as react-three-rapier:- Library handles MuJoCo engine concerns only: WASM lifecycle, physics stepping, body rendering
- Controllers are opt-in plugins: IK, teleoperation, custom controllers are composable components
- Consumers compose everything else: lights, grid, camera controls, UI, game logic
- All scene elements are R3F children: no config objects for visual-only things
<MujocoCanvas> wraps R3F <Canvas> and forwards all Canvas props. For full control over the Canvas (gl settings, post-processing, etc.), use <MujocoPhysics> inside your own:
- MujocoCanvas
- MujocoPhysics