Using the React Profiler
In this page:
Recording a Profiling Session
The Profiler tab in React DevTools lets you click record, perform some interaction in your app (like typing in a search box or clicking a button), then stop recording to see exactly which components rendered, how long each took, and why.
Note: Record a focused, specific interaction (not just random clicking around) so the resulting data is easy to interpret.
Warning: The Profiler is a browser extension feature — it can't be demonstrated running live inside this code preview, only described here.
Reading the Flame Graph
The Profiler's flame graph shows each component as a colored bar — wider/darker bars represent components that took longer to render. Clicking a specific render (a numbered bar at the top) lets you see exactly which components rendered during that particular update and why.
Note: Look for unexpectedly wide bars for components you didn't expect to be doing much work — that's often where a real optimization opportunity hides.
Warning: A component appearing in the flame graph doesn't automatically mean it's a problem — check both how OFTEN it renders and how LONG each render actually takes.
Profiling with a Production-Like Build
React's development build includes extra warnings and checks that make it noticeably slower than a real production build. For accurate, real-world performance numbers, profile against a production build (or React's profiling build), not the default development server.
Note: Most bundlers (Vite, webpack via Create React App) offer a way to build a profiling-enabled production bundle specifically for this purpose.
Warning: Development-mode timings can be significantly slower than production, potentially making you optimize for a problem that doesn't actually exist in the real, deployed app.
Example: Building and Previewing Before Profiling
$ npm run build
vite v5.0.0 building for production...
✓ 34 modules transformed.
$ npm run preview
➜ Local: http://localhost:4173/
# open React DevTools Profiler against this URL, not the dev server
⚠️ Run this command in your terminal.
- Guessing which components are slow instead of actually recording and reading a Profiler session.
- Profiling in development mode and assuming those exact timings apply to production (development builds include extra checks that slow things down).
- Not using the 'Why did this render?' feature/flame graph to understand the ACTUAL cause of a re-render before trying to fix it.
- The React DevTools Profiler tab records render timings for every component during an interaction.
- The flame graph visualizes which components took the most time, and how often they re-rendered.
- Profiling should happen with a production-like build when checking actual real-world performance numbers.
- Use the Profiler's data to target specific slow components, rather than guessing where to optimize.
React DevTools extension supports the Profiler for React 16.5+.
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first:
- Why Performance Matters
- Optimizing with React.memo
- Avoiding Unnecessary Re-renders
- Using the React Profiler
- Analyzing Bundle Size
- Image Optimization Techniques
- React as a PWA
- Creating a Production Build
- Environment Variables in React
- Deploying to Netlify
- Deploying to Vercel
- Basic CI/CD for React Apps
- SEO Basics for React SPAs