'react-babylonjs' integrates the Babylon.js real time 3D engine with React
react-babylonjs lets you build your scene and components using a familiar
declarative syntax with the benefits of reusable components and hooks. The
Babylon.js API is mostly covered declaratively thanks to code generation and
even custom props allow you to declaratively add shadows, physics, 3D models,
attach 2D/3D UI to meshes, etc.
NOTE: react-babylonjs@4 requires React 19.
For older React versions (React < 19), install from the maintained 3.x line:
yarn add react-babylonjs@^3 (tracked on the r18 branch).
Some limited 3.x versions did support React 19, so you may get caught updating to 3.x that is now React 18 only (not by patch update). In retrospect, I should have made 2 separate majors. The intention at one point was to support both in same npm.
npm i react-babylonjs
yarn add react-babylonjs
Fully supports hooks. Full support for TypeScript with auto-completion on elements and compile time checks. Context API and hooks provide easy access to Scene/Engine/Canvas.
No third party dependencies outside of React + babylon.js
https://brianzinn.github.io/react-babylonjs/
~50 sample web pages with viewable source code on: github pages examples.
No online examples for native, but you can integrate using
EngineCanvasContext.Provider:
import React, { useState } from 'react';
import { View } from 'react-native';
import { EngineView, useEngine } from '@babylonjs/react-native';
import { Camera } from '@babylonjs/core';
import { EngineCanvasContext, Scene } from 'react-babylonjs';
const EngineScreen: FunctionComponent<ViewProps> = (props: ViewProps) => {
const engine = useEngine();
const [camera, setCamera] = useState<Camera>();
return (
<View style={props.style}>
<EngineCanvasContext.Provider value={{ engine, canvas: null }}>
{engine &&
<Scene>
<arcRotateCamera
name="camera1"
onCreated={camera => setCamera(camera)}
/>
<hemisphericLight name="light1" />
{ /* rest of declarative scene/components here */ }
</Scene>
}
</EngineCanvasContext.Provider>
<EngineView camera={camera} displayFrameRate={true} />
</View>
);
};
react-babylon-spring -
https://github.com/hookex/react-babylon-spring.CascadedShadowGenerator, createPortal and Html (project HTML in scene -
ported from drei). Also, stories for
Snippet Material
and
"tunnel" zustand integration.
Added RenderOnDemand to customize render loops.<pointsCloudSystem .../> as host
element.react-babylon-spring integration and added GH action for Storybook
(github pages)isPaused Engine prop to skip
renderingThanks also to all the people who have contributed with issues/questions/discussions. All the great ideas and requests are why this project evolved beyond an experiment.
Made with ♥
$ claude mcp add react-babylonjs \
-- python -m otcore.mcp_server <graph>