react-performance-profiler
v1.0.1
Published
A React performance profiling and render analysis tool.
Downloads
188
Maintainers
Readme
React Performance Profiler
Understand Every React Render.
Automatically detect unnecessary re-renders, prop instability, and performance bottlenecks in your React applications.
🚨 The Problem
Debugging React performance is difficult, tedious, and often feels like a guessing game.
- Finding unnecessary re-renders across a large component tree is extremely time-consuming.
- React DevTools is powerful, but it shows raw data without actionable explanations or context.
- Identifying why a set of props caused a component to render involves manual deep-dives and countless
console.logstatements.
Developers waste hours trying to find the root cause of sluggish application performance.
💡 The Solution
React Performance Profiler analyzes your React component tree in real-time and tells you exactly why components are rendering.
Instead of staring at a waterfall of incomprehensible data, this tool provides human-readable explanations, clear visual indicators, and actionable suggestions to instantly fix performance issues before they hit production.
✨ Features
- 🕵️ Render Tracking & Cause Analysis: See exactly which state or prop change caused any component to re-render.
- 🐢 Slow Component Detection: Instantly identify components with rendering times that exceed your performance budget.
- 🪃 Prop Instability Detection: Catch inline functions and objects that break React's memoization automatically.
- 📊 Render Heatmap Visualization: Visually spot problematic areas of your app with intuitive heatmaps.
- 🎯 Optimization Suggestions: Get precise recommendations (e.g., "Wrap Component in
React.memo", "MemoizeonClickprop withuseCallback"). - ⏱️ Zero Overhead in Production: Safely include in your app; simply disable the provider in your production build.
⚖️ Feature Comparison
| Feature | React Profiler API | React Performance Profiler | | :--- | :---: | :---: | | Measure render time | ✅ | ✅ | | Component render count | ❌ | ✅ | | Render cause detection | ❌ | ✅ | | Performance warnings | ❌ | ✅ | | Optimization suggestions | ❌ | ✅ | | Visual dashboard | ❌ | ✅ | | Flame graphs | ❌ | ✅ | | AI analysis | ❌ | ✅ |
📸 Demo
Get a clear, automated breakdown of your app's performance in real time:
| Performance Report | Status |
| :--- | :--- |
| 🐢 Slow Components | <DataGrid /> (24ms) - Exceeds budget |
| 🔁 Frequent Renders | <Avatar /> rendered 42 times |
| 💡 Suggestion | ⚠️ The data prop reference on <DataGrid /> changes every render. Wrap the value in useMemo. |
(Add a screenshot or GIF of your profiler overlay here to maximize conversion)
📦 Installation
Installing react-performance-profiler takes less than a minute.
npm install react-performance-profileror
pnpm add react-performance-profileror
yarn add react-performance-profiler🚀 Quick Start
To start profiling, simply wrap your top-level application component with the ProfilerProvider.
import React from 'react';
import { createRoot } from 'react-dom/client';
import { ProfilerProvider, Dashboard } from 'react-performance-profiler';
import App from './App';
const root = createRoot(document.getElementById('root')!);
root.render(
<React.StrictMode>
<ProfilerProvider active={process.env.NODE_ENV === 'development'}>
<App />
</ProfilerProvider>
<Dashboard />
</React.StrictMode>
);That's it! Your app is now being profiled, and you can view the dashboard alongside your components.
🔺 Using with Next.js (App Router)
Since the profiler relies on React Context and Hooks, it must be rendered as a Client Component in the Next.js App Router.
- Create a Client Component wrapper (e.g.,
components/PerformanceProfiler.tsx):
"use client";
import React from 'react';
import { ProfilerProvider, Dashboard } from 'react-performance-profiler';
export default function PerformanceProfiler({ children }: { children: React.ReactNode }) {
const isDev = process.env.NODE_ENV === 'development';
return (
<>
<ProfilerProvider active={isDev}>
{children}
</ProfilerProvider>
{isDev && <Dashboard />}
</>
);
}- Wrap your application in
app/layout.tsx:
import PerformanceProfiler from '@/components/PerformanceProfiler';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<PerformanceProfiler>
{children}
</PerformanceProfiler>
</body>
</html>
)
}🔺 Using with Next.js (Pages Router)
Wrap your application in pages/_app.tsx:
import type { AppProps } from 'next/app'
import { ProfilerProvider, Dashboard } from 'react-performance-profiler';
export default function App({ Component, pageProps }: AppProps) {
const isDev = process.env.NODE_ENV === 'development';
return (
<>
<ProfilerProvider active={isDev}>
<Component {...pageProps} />
</ProfilerProvider>
{isDev && <Dashboard />}
</>
)
}⚙️ How It Works
Under the hood, react-performance-profiler operates through a seamless, lightweight architecture designed specifically for modern React:
- Profiler SDK: Wraps your components, non-intrusively gathering React Fiber data.
- Render Tracking Engine: Tracks commit phases, measuring execution times and deep-comparing prev/next props layer by layer.
- Analysis Engine: Evaluates the collected data against known performance anti-patterns (e.g., inline object allocations, excessive render counts).
- Dashboard / Overlay: Projects the processed telemetry directly onto your screen, highlighting trouble spots.
🤔 Why This Tool Exists
React's reactive model is brilliant, but it's remarkably easy to introduce hidden performance leaks through a simple mismanaged dependency array or an inline arrow function.
React developers spend hours debugging these render behaviors manually because built-in tools only show that that a render happened, not why it happened or how to fix it. We built this tool to make React performance transparent, accessible, and solvable so you can get back to building features.
🗺️ Roadmap
We're constantly working to make the profiler even more powerful. Upcoming features include:
- [ ] AI Performance Insights: Automated natural language summaries of complex bottlenecks.
- [ ] Flame Graph Visualization: Native chronological timeline mapping for deep dive investigations.
- [ ] Chrome DevTools Integration: A dedicated browser extension panel.
- [ ] CI Performance Checks: Fail your CI pipeline if a PR introduces significant render degradation.
🤝 Contributing
We love community contributions! Whether you're fixing bugs, adding new visualizations, or improving our documentation, your help makes this tool better for everyone.
Please see our CONTRIBUTING.md for:
- Pull request guidelines
- Issue reporting steps
- Local development instructions & coding standards
📄 License
This project is licensed under the MIT License. See the LICENSE file for more details.
