React Three Fiber Grid Notes
Declarative React renderer for Three.js with zero reconciler overhead, letting you build 3D scenes with components, hooks and suspense.
Install and prerequisites
npm install three @react-three/fiber && npm install -D @types/threethree@react-three/fiber@types/threeUse @react-three/fiber@^9 with React 19 (or ^8 with React 18). In Next.js, add transpilePackages: ['three'] to next.config.ts.
Framework setup
On-demand rendering Canvas with reduced-motion fallback
Set frameloop="demand" (or "never" when off-screen) so the GPU isn't pegged at 60 fps when nothing in the 3D scene is moving.
"use client";
import { useRef } from "react";
import { Canvas, useFrame } from "@react-three/fiber";
import type { Mesh } from "three";
function SpinningCube({ animate }: { animate: boolean }) {
const meshRef = useRef<Mesh>(null);
useFrame((_state, delta) => {
if (!animate || !meshRef.current) return;
meshRef.current.rotation.y += delta * 0.6;
});
return (
<mesh ref={meshRef}>
<boxGeometry args={[1.5, 1.5, 1.5]} />
<meshStandardMaterial color="#4f46e5" />
</mesh>
);
}
export function SceneCanvas({ reducedMotion = false }: { reducedMotion?: boolean }) {
return (
<div role="img" aria-label="3D preview cube" className="h-64 w-full">
<Canvas frameloop={reducedMotion ? "demand" : "always"} dpr={[1, 2]}>
<ambientLight intensity={0.8} />
<directionalLight position={[3, 4, 5]} intensity={1.2} />
<SpinningCube animate={!reducedMotion} />
</Canvas>
</div>
);
}Gotchas for agents
Never call setState inside useFrame
useFrameruns on every animation frame (60–120 Hz). Triggering React state updates insideuseFramecauses catastrophic re-render lag; mutateref.current.position/rotationdirectly instead.Match R3F major version to React major version
@react-three/fiberv9 targets React 19's reconciler; v8 targets React 18. Mixing React 19 with R3F v8 throwsReactCurrentOwnerruntime errors.Cap device pixel ratio and frameloop
Always pass
dpr={[1, 2]}to<Canvas>so 3×/4× mobile screens don't render 9–16× the pixels, and useframeloop="demand"whenever the scene only updates on interaction.
Accessibility and reduced motion
Reduced motion
Switch <Canvas frameloop={reducedMotion ? 'demand' : 'always'}> and guard continuous useFrame camera or mesh motion when prefers-reduced-motion: reduce is active.
Keyboard and screen readers
WebGL canvases are opaque to assistive tech. Give the wrapper role="img" with an aria-label (or @react-three/a11y for interactive 3D objects) so keyboard users can focus and activate controls without a pointer.
More Grid Notes
- shadcn/uiCopy-in React components built on Base UI or Radix UI and Tailwind CSS v4, plus an official MCP server that searches and installs from any namespaced registry.
- React BitsAnimated text effects, shaders, cursors and interactive backgrounds installed as source code in four variants (`-JS-CSS`, `-JS-TW`, `-TS-CSS`, `-TS-TW`).
- Magic UIOver 150 animated landing-page components — marquees, Bento grids, shimmer buttons, globes and device mocks — built with React, Tailwind CSS and Motion.
- Aceternity UIDramatic landing-page hero sections, 3D card perspectives, spotlights, beams and macbook scroll effects built with React 19, Tailwind CSS v4 and Motion.
- Motion PrimitivesComposable, minimal React motion building blocks — animated groups, text effects, morphing dialogs, docks and carousels — built on Motion and Tailwind CSS.
- coss uiOpen-source React components built on Base UI (`@base-ui/react`) and Tailwind CSS v4 (formerly Origin UI; `originui.com` redirects here).


