Catch performance issues before they reach production
Quick Start โข Features โข Documentation โข Examples
react-perf-guard (Performance Guard) is a development-first performance guardrail for React applications that continuously monitors component rendering during development and automatically detects performance issues, regressions, and UX risks โ before they ever reach production.
It's a dev-only runtime performance analysis tool that works silently in the background, applying a rule-based analysis engine to surface clear, actionable signals instead of noisy metrics.
Think of it as ESLint for runtime performance โ continuous, automatic, and built for developers.
- React DevTools Profiler requires manual intervention
- Lighthouse runs after performance degradation occurs
- Performance regressions slip through silently
- Console logs create noise and alert fatigue
- Teams lack continuous performance feedback
- Performance audits happen too late in the cycle
- Automatic render performance detection
- Continuous monitoring during development
- Intelligent rule-based insights
- Deduplicated issue reporting
- Trend & regression detection
- Real-time performance feedback
| Traditional Approach | react-perf-guard |
|---|---|
| Manual profiling sessions | โจ Automatic detection |
| One-time snapshots | ๐ Continuous monitoring |
| Raw timing numbers | ๐ฏ Rule-based insights |
| Console spam | ๐ Deduplicated issues |
| No historical data | ๐ Trend & regression analysis |
| Post-development audits | ๐ Development-time prevention |
Make performance a continuous development signal โ not a last-minute crisis.
|
Monitors component renders without manual profiling sessions |
Detects performance degradation through trend analysis |
Confidence-based system prevents false positives |
|
Boundary-aware severity tuning for accurate reporting |
Suppresses one-off spikes and repetitive warnings |
Visual dashboard for tracking issues in real-time |
|
Automatically disabled in production builds |
Analysis runs off-thread for zero impact |
Works with Next.js, Create React App, Vite |
โโโโโโโโโโโโโโโโโโโโโโโ
โ React Profiler โ โ Captures component render metrics
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Metrics Collector โ โ Batches data in-memory
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Batch Flush โ โ Sends metrics at intervals
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Analyzer Web Worker โ โก Runs off the main thread
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Rule Engine โ โ Evaluates performance patterns
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Issue Aggregation โ โ Deduplicates & prioritizes
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ
โ Panel โ โ Alerts โ
โโโโโโโโโโโ โโโโโโโโโโโโ
Architecture Overview:
- React Profiler captures render metrics from instrumented components
- Metrics Collector batches data in-memory for efficiency
- Batch Flush sends accumulated metrics at intervals
- Analyzer Web Worker processes data off the main thread
- Rule Engine evaluates performance patterns against rules
- Issue Aggregation deduplicates and prioritizes findings
- PerfGuard Panel displays actionable insights to developers
All heavy analysis runs in a Web Worker, keeping your application fast and responsive.
# Using npm
npm install react-perf-guard
# Using pnpm
pnpm add react-perf-guard
# Using yarn
yarn add react-perf-guardRequirements:
- React 16.8+ (Hooks support)
- Development environment (automatically disabled in production)
The PerfProvider is the entry point that initializes the performance monitoring system.
import { PerfProvider } from "react-perf-guard";
export function App() {
return (
<PerfProvider>
<YourApp />
</PerfProvider>
);
}What happens under the hood:
- โ Starts the analyzer worker thread
- โ Loads performance rules into the engine
- โ Begins automatic metric flushing
- โ Mounts the PerfGuard Panel UI
๐ Production Safety:
react-perf-guardautomatically disables itself in production with zero overhead.
Choose the approach that fits your code style. Both methods use React's built-in Profiler API internally.
Perfect for wrapping existing components without modifying their structure.
import { withPerfGuard } from "react-perf-guard";
function HeavyComponent() {
return <div>Heavy UI rendering logic</div>;
}
// Wrap and export
export default withPerfGuard(HeavyComponent);Great for explicit profiling or conditional instrumentation.
import { PerfProfiler } from "react-perf-guard";
export function ProductPage() {
return (
<PerfProfiler id="ProductList">
<ProductList />
</PerfProfiler>
);
}Best Practices:
- Instrument components at route/page boundaries
- Profile known performance-sensitive components
- Use descriptive IDs for easier debugging
The PerfGuard Panel is your performance command center โ a visual dashboard that appears automatically in development.
|
|
The panel is your single source of truth for React performance issues during development.
When critical performance issues are detected, react-perf-guard escalates visibility to ensure you don't miss user-impacting problems.
Critical issues indicate likely user-visible UX problems such as:
- Render times exceeding 100ms (blocking the main thread)
- Repeated severe performance degradation
- High-confidence regression detection
- ๐ด Visually Highlighted: Red indicators in the panel
- ๐ข Reported Once: Per component lifecycle to avoid spam
- ๐ Persistent Display: Remains visible until resolved
- ๐ฏ High Priority: Sorted to the top of the issue list
This prevents alert fatigue while ensuring serious regressions get immediate attention.
Boundary types provide context-aware severity tuning โ the same render time means different things for different component types.
| Boundary Type | Description | Example Use Cases | Severity Adjustment |
|---|---|---|---|
| INLINE | Small child component | Buttons, icons, labels | Softened (higher threshold) |
| ROUTE | Page or route boundary | Full page components | Standard severity |
| LAYOUT | Layout or shell component | Navigation, sidebars, wrappers | Moderate severity |
A 50ms render might be:
- โ Acceptable for a route-level page component
โ ๏ธ Concerning for a layout shell- ๐จ Critical for an inline button
Boundary types ensure you get accurate, actionable signals instead of false alarms.
The rule engine is the brain of react-perf-guard, transforming raw metrics into actionable performance insights.
Current Render Snapshot + Historical Data
โ
Declarative Rule Evaluation
โ
Pattern & Trend Detection
โ
Confidence Score Calculation
โ
Issue Classification
- ๐ Declarative Rules: Define what to look for, not how to find it
- ๐ Historical Context: Evaluates current performance against past trends
- ๐๏ธ Confidence-Based: Scores increase only when issues persist
- ๐ก๏ธ False Positive Prevention: Ignores one-off spikes and anomalies
- ๐ Adaptive: Learns normal patterns for each component
Perfect for long development sessions and real feature work, not just contrived demos.
react-perf-guard is designed with production safety as the top priority.
// Development: Full monitoring enabled
if (process.env.NODE_ENV === 'development') {
// โ
React Profiler active
// โ
Web Worker running
// โ
Rule engine processing
// โ
Dev Panel visible
// โ
Metrics collection active
}
// Production: Everything disabled
if (process.env.NODE_ENV === 'production') {
// โ No React Profiler
// โ No Web Worker
// โ No Dev Panel
// โ No memory overhead
// โ No runtime cost
}- No bundle size impact (tree-shaken away)
- No memory allocation for metrics
- No CPU cycles for analysis
- No network requests for reporting
- No visual components rendered
Safe by default. Zero cost in production. Guaranteed.
react-perf-guard works seamlessly with both Next.js routing paradigms.
Wrap your application in _app.tsx:
import type { AppProps } from "next/app";
import { PerfProvider } from "react-perf-guard";
export default function MyApp({ Component, pageProps }: AppProps) {
return (
<PerfProvider>
<Component {...pageProps} />
</PerfProvider>
);
}Create a client-side provider component:
// app/providers.tsx
"use client";
import { PerfProvider } from "react-perf-guard";
import { ReactNode } from "react";
export function Providers({ children }: { children: ReactNode }) {
return <PerfProvider>{children}</PerfProvider>;
}Then use it in your root layout:
// app/layout.tsx
import { Providers } from "./providers";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<Providers>{children}</Providers>
</body>
</html>
);
}- Create React App: Wrap in
src/index.tsx - Vite: Wrap in
src/main.tsx - Remix: Wrap in
app/root.tsx
We're actively developing features to make react-perf-guard even more powerful:
|
|
Want to contribute? We welcome PRs and feature suggestions!
- Documentation: Full API Reference (coming soon)
- Examples: GitHub Examples Repository (coming soon)
- Blog: Performance Best Practices (coming soon)
We welcome contributions! Whether it's:
- ๐ Bug reports
- ๐ก Feature suggestions
- ๐ Documentation improvements
- ๐ง Code contributions
Please check our contributing guidelines before submitting a PR.
MIT ยฉ Amiya Das
Performance should fail early, clearly, and with context.
react-perf-guard transforms performance from a last-minute fire drill into a daily development habit.
Stop shipping performance regressions. Start building faster React apps.
npm install react-perf-guardGet Started โข View Examples โข Read Docs
Made with โก for React developers who care about performance
Star this repo if you find it useful! โญ