React Three Fiber
React renderer for Three.js enabling 3D graphics with component patterns.
3. Used by agents' projects
Dependency in 73 public GitHub projects set up for AI coding agents that we scanned (1.2%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
r3f.docs.pmnd.rs/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What React Three Fiber does
React renderer for Three.js enabling 3D graphics with component patterns.
React Three Fiber popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How React Three Fiber is used
- React Three Fiber is a dependency in 73 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.5% of the 4,867 JavaScript/TypeScript ones), #3 of 63 in 3d and graphics.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,712; those are left out of every share on this page.
- The most used alternative in our scan is Pixi.js (9 projects).
- Projects that use it most often also use Three.js (97.3%), clsx (80.8%), Tailwind Merge (76.7%).
By coding agent
Often used with
React Three Fiber in practice
Strengths
JSX elements are created from three.js itself, so a feature added in a new three.js release is usable without waiting for an R3F update. The maintainers put it as: "Everything that works in Threejs will work here without exception."
A component can hold its own state, react to clicks and hovers (<code>onClick</code>, <code>onPointerOver</code>) and subscribe to the render loop with <code>useFrame</code>, which makes models, controls and effects reusable across pages.
Drei (ready-made helpers), postprocessing effects, Rapier and Cannon physics, WebXR, WebGL UI (uikit) and gltfjsx, which turns a GLTF model into a JSX component. Our scan shows how far this goes: see the ecosystem chart below.
The docs say there is "no overhead" compared with plain three.js because components render outside of React, and offer on-demand rendering (<code>frameloop="demand"</code>) so idle scenes stop drawing frames.
Watch out for
R3F is a React renderer and follows React's major version: v8 pairs with React 18, v9 with React 19.
The README asks newcomers to know React hooks and the basics of three.js (scene, camera, mesh, geometry, material) before starting.
Fast changes belong in <code>useFrame</code>, mutating a ref and scaling by the frame delta; calling <code>setState</code> every frame or on pointer moves routes each update through React and slows the scene.
A clickable, spinning box
import { Canvas, useFrame } from '@react-three/fiber'
import { useRef, useState } from 'react'
function Box(props) {
const ref = useRef()
const [hovered, hover] = useState(false)
const [clicked, click] = useState(false)
useFrame((state, delta) => (ref.current.rotation.x += delta))
return (
<mesh {...props} ref={ref} scale={clicked ? 1.5 : 1}
onClick={() => click(!clicked)}
onPointerOver={() => hover(true)} onPointerOut={() => hover(false)}>
<boxGeometry args={[1, 1, 1]} />
<meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} />
</mesh>
)
}
export default function App() {
return (
<Canvas>
<ambientLight intensity={Math.PI / 2} />
<spotLight position={[10, 10, 10]} angle={0.15} penumbra={1} decay={0} intensity={Math.PI} />
<Box position={[-1.2, 0, 0]} />
<Box position={[1.2, 0, 0]} />
</Canvas>
)
}
More about React Three Fiber
Funding
- GitHub Sponsors: https://github.com/drcmda
- Open Collective: https://opencollective.com/react-three-fiber
- 9 GitHub sponsors
Agent Skills for it
- react-three-fiber: React Three Fiber 3D renderer for json-render. Use when working with @json-render/react-three-fiber, building 3D scenes from JSON specs, ren
Packages around it
- @react-three/drei: Drei (helpers)
- @types/three: three.js types
- gsap: GSAP
- @react-three/postprocessing: Postprocessing
- zustand: Zustand
- maath: maath
More in 3D and graphics
Alternatives
React Three Fiber This page
Fast 2D WebGL renderer for interactive graphics, games and animations.
Get started
Install it.
npm install @react-three/fiberRules for your agent
## React Three Fiber
- Keep @react-three/fiber on the major that matches React: v8 for React 18, v9 for React 19.
- Animate inside useFrame by mutating refs and multiplying by delta; never call setState every frame or on pointer move.
- Reuse geometries and materials (useMemo or module scope); use instancing for repeated objects; keep draw calls in the hundreds.
- Hide heavy parts with visible={false} instead of mounting and unmounting them.
- For mostly static scenes use <Canvas frameloop="demand"> and call invalidate() after changing three.js objects directly.
- Load models with useLoader / Drei's useGLTF (cached by URL); turn GLTF files into components with gltfjsx.
- Docs for lookups: https://r3f.docs.pmnd.rs/llms.txt