Gathering detailed insights and metrics for @react-three/fiber
Gathering detailed insights and metrics for @react-three/fiber
Gathering detailed insights and metrics for @react-three/fiber
Gathering detailed insights and metrics for @react-three/fiber
@react-three/drei
useful add-ons for react-three-fiber
react-three-fiber
A React renderer for Threejs
@react-spring/three
[`react-three-fiber`](https://github.com/drcmda/react-three-fiber) support. This package is for version 6 of react-three-fiber
@react-three/postprocessing
postprocessing wrapper for React and @react-three/fiber
npm install @react-three/fiber
Typescript
Module System
Node Version
NPM Version
60.8
Supply Chain
37.6
Quality
81.2
Maintenance
50
Vulnerability
89
License
TypeScript (98.69%)
CSS (0.82%)
JavaScript (0.36%)
HTML (0.11%)
Shell (0.02%)
Total Downloads
46,864,945
Last Day
37,924
Last Week
620,809
Last Month
2,645,981
Last Year
22,814,083
MIT License
29,145 Stars
2,765 Commits
1,700 Forks
211 Watchers
24 Branches
234 Contributors
Updated on Jul 01, 2025
Minified
Minified + Gzipped
Latest Version
9.1.4
Package Id
@react-three/fiber@9.1.4
Unpacked Size
389.13 kB
Size
93.80 kB
File Count
32
NPM Version
11.2.0
Node Version
24.1.0
Published on
Jun 29, 2025
Cumulative downloads
Total Downloads
Last Day
-24.6%
37,924
Compared to previous day
Last Week
-11.4%
620,809
Compared to previous week
Last Month
5.2%
2,645,981
Compared to previous month
Last Year
62%
22,814,083
Compared to previous year
react-three-fiber is a React renderer for threejs.
Build your scene declaratively with re-usable, self-contained components that react to state, are readily interactive and can participate in React's ecosystem.
1npm install three @react-three/fiber
None. Everything that works in Threejs will work here without exception.
No. There is no overhead. Components render outside of React. It outperforms Threejs in scale due to React's scheduling abilities.
Yes. It merely expresses Threejs in JSX: <mesh />
becomes new THREE.Mesh()
, and that happens dynamically. If a new Threejs version adds, removes or changes features, it will be available to you instantly without depending on updates to this library.
Let's make a re-usable component that has its own state, reacts to user-input and participates in the render-loop. (live demo). |
![]() |
1import { createRoot } from 'react-dom/client' 2import React, { useRef, useState } from 'react' 3import { Canvas, useFrame } from '@react-three/fiber' 4 5function Box(props) { 6 // This reference gives us direct access to the THREE.Mesh object 7 const ref = useRef() 8 // Hold state for hovered and clicked events 9 const [hovered, hover] = useState(false) 10 const [clicked, click] = useState(false) 11 // Subscribe this component to the render-loop, rotate the mesh every frame 12 useFrame((state, delta) => (ref.current.rotation.x += delta)) 13 // Return the view, these are regular Threejs elements expressed in JSX 14 return ( 15 <mesh 16 {...props} 17 ref={ref} 18 scale={clicked ? 1.5 : 1} 19 onClick={(event) => click(!clicked)} 20 onPointerOver={(event) => hover(true)} 21 onPointerOut={(event) => hover(false)}> 22 <boxGeometry args={[1, 1, 1]} /> 23 <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> 24 </mesh> 25 ) 26} 27 28createRoot(document.getElementById('root')).render( 29 <Canvas> 30 <ambientLight /> 31 <pointLight position={[10, 10, 10]} /> 32 <Box position={[-1.2, 0, 0]} /> 33 <Box position={[1.2, 0, 0]} /> 34 </Canvas>, 35)
1npm install @types/three
1import * as THREE from 'three' 2import { createRoot } from 'react-dom/client' 3import React, { useRef, useState } from 'react' 4import { Canvas, useFrame, ThreeElements } from '@react-three/fiber' 5 6function Box(props: ThreeElements['mesh']) { 7 const ref = useRef<THREE.Mesh>(null!) 8 const [hovered, hover] = useState(false) 9 const [clicked, click] = useState(false) 10 useFrame((state, delta) => (ref.current.rotation.x += delta)) 11 return ( 12 <mesh 13 {...props} 14 ref={ref} 15 scale={clicked ? 1.5 : 1} 16 onClick={(event) => click(!clicked)} 17 onPointerOver={(event) => hover(true)} 18 onPointerOut={(event) => hover(false)}> 19 <boxGeometry args={[1, 1, 1]} /> 20 <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> 21 </mesh> 22 ) 23} 24 25createRoot(document.getElementById('root') as HTMLElement).render( 26 <Canvas> 27 <ambientLight /> 28 <pointLight position={[10, 10, 10]} /> 29 <Box position={[-1.2, 0, 0]} /> 30 <Box position={[1.2, 0, 0]} /> 31 </Canvas>, 32)
Live demo: https://codesandbox.io/s/icy-tree-brnsm?file=/src/App.tsx
This example relies on react 18 and uses expo-cli
, but you can create a bare project with their template or with the react-native
CLI.
1# Install expo-cli, this will create our app 2npm install expo-cli -g 3# Create app and cd into it 4expo init my-app 5cd my-app 6# Install dependencies 7npm install three @react-three/fiber react 8# Start 9expo start
Some configuration may be required to tell the Metro bundler about your assets if you use useLoader
or Drei abstractions like useGLTF
and useTexture
:
1// metro.config.js 2module.exports = { 3 resolver: { 4 sourceExts: ['js', 'jsx', 'json', 'ts', 'tsx', 'cjs'], 5 assetExts: ['glb', 'png', 'jpg'], 6 }, 7}
1import React, { useRef, useState } from 'react' 2import { Canvas, useFrame } from '@react-three/fiber/native' 3function Box(props) { 4 const mesh = useRef(null) 5 const [hovered, setHover] = useState(false) 6 const [active, setActive] = useState(false) 7 useFrame((state, delta) => (mesh.current.rotation.x += delta)) 8 return ( 9 <mesh 10 {...props} 11 ref={mesh} 12 scale={active ? 1.5 : 1} 13 onClick={(event) => setActive(!active)} 14 onPointerOver={(event) => setHover(true)} 15 onPointerOut={(event) => setHover(false)}> 16 <boxGeometry args={[1, 1, 1]} /> 17 <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> 18 </mesh> 19 ) 20} 21export default function App() { 22 return ( 23 <Canvas> 24 <ambientLight /> 25 <pointLight position={[10, 10, 10]} /> 26 <Box position={[-1.2, 0, 0]} /> 27 <Box position={[1.2, 0, 0]} /> 28 </Canvas> 29 ) 30}
Visit docs.pmnd.rs
You need to be versed in both React and Threejs before rushing into this. If you are unsure about React consult the official React docs, especially the section about hooks. As for Threejs, make sure you at least glance over the following links:
Some reading material:
@react-three/gltfjsx
– turns GLTFs into JSX components@react-three/drei
– useful helpers for react-three-fiber@react-three/postprocessing
– post-processing effects@react-three/flex
– flexbox for react-three-fiber@react-three/xr
– VR/AR controllers and events@react-three/cannon
– physics based hooks@react-three/a11y
– real a11y for your scenezustand
– state managementreact-spring
– a spring-physics-based animation libraryreact-use-gesture
– mouse/touch gesturesleva
– create GUI controls in secondsIf you like this project, please consider helping out. All contributions are welcome as well as donations to Opencollective, or in crypto BTC: 36fuguTPxGCNnYZSRdgdh6Ea94brCAjMbH
, ETH: 0x6E3f79Ea1d0dcedeb33D3fC6c34d2B1f156F2682
.
Thank you to all our backers! 🙏
This project exists thanks to all the people who contribute.
No vulnerabilities found.
Reason
14 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/23 approved changesets -- score normalized to 3
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More