A comprehensive React performance optimization toolkit that automatically detects, analyzes, and provides solutions for performance bottlenecks in your React applications.
Video:
npm_package_test.mp4
![]() |
![]() |
![]() |
![]() |
🔍 Real-time Performance Monitoring
- Component render tracking
- Props change detection
- Memory usage analysis
- Bundle size monitoring
- Automatic bottleneck detection
⚡ Automated Optimization Suggestions
- Memoization opportunities
- Code splitting recommendations
- Component render optimization
- State management improvements
- Bundle size reduction tips
📊 Performance Visualization
- Component render tree
- Performance metrics dashboard
- Historical performance data
- Bundle size analysis
- Memory usage graphs
🔧 Developer Tools
- Chrome DevTools extension
- VS Code integration
- CI/CD pipeline integration
- Custom ESLint rules
- Performance regression testing
npm install react-perf-optimizer
# or with yarn
yarn add react-perf-optimizer
- Wrap your app with the Performance Provider:
import { PerformanceProvider } from 'react-perf-optimizer';
function App() {
return (
<PerformanceProvider>
<YourApp />
</PerformanceProvider>
);
}
- Monitor specific components:
import { withPerformanceTracking } from 'react-perf-optimizer';
function MyComponent() {
return <div>My Component</div>;
}
export default withPerformanceTracking(MyComponent);
- Access performance metrics:
import { usePerformanceMetrics } from 'react-perf-optimizer';
function PerformancePanel() {
const metrics = usePerformanceMetrics();
return (
<div>
<h2>Performance Metrics</h2>
<pre>{JSON.stringify(metrics, null, 2)}</pre>
</div>
);
}
# Install the package
npm install react-perf-optimizer
# Analyze component with all features
npx react-perf-optimizer analyze ./src/components/MyComponent.js -r -m -p
# Remove comments and create backup
npx react-perf-optimizer analyze ./src/components/MyComponent.js -c
# Get memoization suggestions only
npx react-perf-optimizer analyze ./src/components/MyComponent.js -m
Create a perf-optimizer.config.js
file in your project root:
module.exports = {
thresholds: {
renderDuration: 16, // ms
memoryUsage: 50 * 1024 * 1024, // 50MB
bundleSize: 244 * 1024, // 244KB
},
monitoring: {
enabled: true,
interval: 1000,
trackProps: true,
trackState: true,
trackEvents: true,
},
};
The root provider that enables performance monitoring.
<PerformanceProvider
config={config}
onAlert={handleAlert}
onMetricsUpdate={handleMetricsUpdate}
>
{children}
</PerformanceProvider>
HOC for monitoring individual components.
withPerformanceTracking(Component, options);
Options:
-
trackProps
: Boolean -
trackState
: Boolean -
trackEvents
: Boolean -
customMetrics
: Array -
thresholds
: Object
// Get performance metrics
const metrics = usePerformanceMetrics();
// Track custom metrics
const track = usePerformanceTracker();
// Get optimization suggestions
const suggestions = useOptimizationSuggestions();
name: Performance Checks
on: [push, pull_request]
jobs:
performance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Run performance tests
uses: react-perf-optimizer/github-action@v1
with:
thresholds: |
{
"bundleSize": "244KB",
"renderTime": "16ms"
}
-
Component Optimization
- Use memoization for expensive calculations
- Implement
React.memo
for pure components - Optimize event handlers with
useCallback
- Use
useMemo
for expensive derivations
-
State Management
- Keep state as local as possible
- Use appropriate state management tools
- Implement proper state splitting
- Optimize context usage
-
Bundle Optimization
- Implement code splitting
- Use dynamic imports
- Optimize dependencies
- Configure proper splitting points
- Fork the repository
- Create your feature branch
- Submit a pull request
MIT © Divit Patidar