R3F Learning Docs is an Astro + Starlight site for learning React Three Fiber by comparing familiar Three.js patterns with their React equivalents.
Each lesson follows a simple loop:
- Read the Three.js version.
- Switch to the React Three Fiber version.
- Run the R3F example inline with the local preview embedded in the page.
start-here/: core mental models for reading and learning R3Fconversions/: side-by-side translations from common Three.js setups to R3Fguides/: broader walkthroughs and supporting explanationspatterns/: practical guidance on refs, state, imperative updates, and helper librariesreference/: quick lookup material for JSX primitives, prop mappings, and common gotchas
The documentation homepage lives at src/content/docs/index.mdx.
The docs use a shared example registry plus inline local previews for the comparison pages.
- Source examples live in
examples/<slug>/ - Each example includes:
three/main.jsfor the vanilla Three.js versionr3f/App.jsxfor the React Three Fiber versionmeta.jsonfor the title, summary, sandbox links, and pinned dependency versions
src/data/examples.tsimports those files and exposes them to the docs componentssrc/components/docs/CodeCompare.astrorenders the tabbed code comparison and mounts the live R3F previewsrc/components/docs/SandpackDemo.tsx,src/components/docs/ExamplePreviewPage.tsx, andsrc/pages/previews/[slug].astropower the inline preview iframe and the dedicated preview route
.
|-- examples/
|-- public/
|-- src/
| |-- components/
| | `-- docs/
| |-- content/
| | `-- docs/
| | |-- conversions/
| | |-- guides/
| | |-- patterns/
| | |-- reference/
| | `-- start-here/
| |-- data/
| |-- pages/
| `-- styles/
|-- astro.config.mjs
|-- package.json
`-- README.md
Run these from the project root:
| Command | Action |
|---|---|
pnpm install |
Install dependencies |
pnpm dev |
Start the local dev server |
pnpm build |
Build the production site into dist/ |
pnpm preview |
Preview the production build locally |
pnpm astro -- --help |
Show Astro CLI help |
- Docs content is written in
.mdand.mdxfiles undersrc/content/docs/. - Static assets belong in
public/. - Shared styling lives in
src/styles/. - Example updates usually touch both the lesson content and the matching files in
examples/. - The inline preview only runs the R3F example; the Three.js version is shown as a comparison reference.
This project is licensed under the MIT License. See LICENSE for details.