# React Three Fiber — A React Renderer for Three.js
> Build interactive 3D scenes declaratively with React components, leveraging the full power of Three.js through a familiar JSX-based API with automatic lifecycle management.
## Install
Save in your project root:
# React Three Fiber — A React Renderer for Three.js
## Quick Use
```bash
npm install three @react-three/fiber @react-three/drei
# In a React component
import { Canvas } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'
export default function Scene() {
return (
)
}
```
## Introduction
React Three Fiber (R3F) is a React renderer for Three.js that lets developers build 3D scenes using declarative JSX syntax. Instead of imperative Three.js boilerplate, you compose scenes with React components, gaining automatic resource disposal, event handling, and integration with the React ecosystem including state management and routing.
## What React Three Fiber Does
- Renders Three.js scenes as React component trees with JSX syntax
- Manages the render loop, resizing, and disposal automatically
- Provides pointer events (click, hover, drag) on 3D objects out of the box
- Integrates with React state and lifecycle for reactive 3D updates
- Works with the @react-three/drei companion library for common 3D helpers
## Architecture Overview
R3F implements a custom React reconciler that maps JSX elements to Three.js objects. Each JSX tag (e.g., ``, ``) creates and manages the corresponding Three.js instance. The reconciler handles mounting, updating props, and unmounting with proper GPU resource cleanup. A built-in render loop drives animation frames, and a raycaster provides DOM-like pointer events on 3D geometry.
## Self-Hosting & Configuration
- Install three, @react-three/fiber, and optionally @react-three/drei for helpers
- Wrap your 3D scene in a `