zebbern/claude-code-guide / skills/r3f-best-practices
r3f-best-practices
VerifiedReact Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.9 KB |
| rules/_sections.md | markdown | 1.9 KB |
| rules/drei-use-gltf.md | markdown | 3.0 KB |
| rules/frame-delta-time.md | markdown | 2.7 KB |
| rules/loading-suspense.md | markdown | 3.6 KB |
| rules/perf-never-set-state-in-useframe.md | markdown | 2.6 KB |
| rules/perf-r3f-perf.md | markdown | 1.9 KB |
| rules/perf-visibility-toggle.md | markdown | 1.9 KB |
| rules/perf-zustand-selectors.md | markdown | 3.0 KB |
rules/perf-r3f-perf.md
View on GitHub# r3f-perf for Performance Monitoring
> Source: [100 Three.js Tips - Utsubo](https://www.utsubo.com/blog/threejs-best-practices-100-tips)
Use r3f-perf for comprehensive React Three Fiber performance monitoring.
## Installation
```bash
npm install r3f-perf
```
## Basic Usage
```jsx
import { Perf } from 'r3f-perf';
function App() {
return (
<Canvas>
<Perf position="top-left" />
<Scene />
</Canvas>
);
}
```
## Available Props
```jsx
<Perf
position="top-left" // Position: top-left, top-right, bottom-left, bottom-right
minimal={false} // Minimal mode (just FPS)
showGraph={true} // Show performance graph
matrixUpdate={true} // Show matrix updates
deepAnalyze={false} // Deep analysis (more CPU intensive)
overClock={false} // Over-clock mode for high refresh rate monitors
logsPerSecond={10} // Logs per second
/>
```
## What It Monitors
- **FPS** - Frames per second
- **MS** - Milliseconds per frame
- **CPU** - JavaScript execution time
- **GPU** - WebGL draw time (estimated)
- **Memory** - Geometries, textures, draw calls
- **Matrix Updates** - Number of matrix recalculations
## Conditional Rendering for Production
```jsx
import { Perf } from 'r3f-perf';
function App() {
const isDev = process.env.NODE_ENV === 'development';
return (
<Canvas>
{isDev && <Perf position="top-left" />}
<Scene />
</Canvas>
);
}
```
## Deep Analyze Mode
For detailed per-object analysis:
```jsx
<Perf
deepAnalyze={true}
className="custom-perf"
/>
```
Shows render times for individual objects but has higher CPU overhead.
## Best Practices
1. **Remove in production** - Always hide in production builds
2. **Use sparingly** - Performance monitor itself has overhead
3. **Check draw calls** - Target under 100 draw calls
4. **Monitor memory** - Watch for leaking geometries/textures
5. **Use alongside renderer.info** - For detailed WebGL stats
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |