1. Import Canvas
Canvas is the root component react-three-fiber renders Three.js into.
import { Canvas } from "@react-three/fiber";Typorithm · medium
Step 1 of 8 · intro card
Three.js & R3F
react-three-fiber renders Three.js declaratively as JSX. <Canvas> sets up the scene, camera, renderer, and render loop for you; lowercase tags map to Three.js classes; nested geometry and material become the mesh's children — far less boilerplate than the imperative API.
react-three-fiber (R3F) is a React renderer for Three.js. Instead of constructing objects imperatively, you write JSX and R3F builds the equivalent scene graph.
<Canvas> is the root: it creates the scene, a default camera, a WebGLRenderer, and a render loop, so you do not wire those up by hand. Everything inside is your 3D content.
Lowercase tags map to Three.js classes — mesh to THREE.Mesh, boxGeometry to THREE.BoxGeometry. Nested geometry and material attach as the mesh's children, and Three.js props like color pass straight through.
<Canvas> sets up scene, camera, renderer, and loop.
Lowercase tags map to Three.js classes.
Nested geometry/material attach to the parent mesh.
import { Canvas } from "@react-three/fiber";
function Scene() {
return (
<Canvas>
<ambientLight />
<mesh>
<boxGeometry />
<meshStandardMaterial color="orange" />
</mesh>
</Canvas>
);
}Connect each part of the code to the concept before you type.
Canvas is the root component react-three-fiber renders Three.js into.
import { Canvas } from "@react-three/fiber";<Canvas> sets up the scene, camera, renderer, and render loop automatically.
<Canvas>Lowercase JSX tags map to Three.js classes — mesh becomes a THREE.Mesh.
<mesh>A nested geometry tag becomes the mesh's geometry — children attach to the parent.
<boxGeometry />The material tag attaches to the mesh and takes Three.js props like color directly.
<meshStandardMaterial color="orange" />Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.