Recipe
React Three Fiber Basics
Render declarative 3D scenes inside React without leaving the component tree.
Setup
npm install three @react-three/fiber @react-three/dreiMinimal Canvas
import { Canvas } from '@react-three/fiber'
export default function Scene() {
return (
<Canvas>
<ambientLight intensity={0.5} />
<pointLight position={[10, 10, 10]} />
<mesh>
<boxGeometry />
<meshStandardMaterial color="#8B5CF6" />
</mesh>
</Canvas>
)
}Key Concepts
- ▸Canvas — mounts the WebGL renderer and sets up the scene context.
- ▸Imperative handles — use
useRefanduseFramefor per-frame updates. - ▸Drei helpers — OrbitControls, Environment, and Text from
@react-three/dreiaccelerate prototyping.