Create React App
Using React Performance Monitoring with Create React App (CRA) requires no special configuration.
Setup
- Install the package:
bash
npm install react-performance-monitoring- Wrap your app root in
src/App.js(orsrc/App.tsx):
tsx
import { DevHUD } from "react-performance-monitoring"
function App() {
return (
<DevHUD>
<div className="App">
{/* your app content */}
</div>
</DevHUD>
)
}
export default AppAlternatively, wrap in src/index.js:
tsx
import React from "react"
import ReactDOM from "react-dom/client"
import { DevHUD } from "react-performance-monitoring"
import App from "./App"
const root = ReactDOM.createRoot(document.getElementById("root"))
root.render(
<React.StrictMode>
<DevHUD>
<App />
</DevHUD>
</React.StrictMode>
)Development
bash
npm startThe HUD appears automatically. CRA sets NODE_ENV=development when running the dev server.
Production Build
bash
npm run buildCRA sets NODE_ENV=production for production builds. The package strips all monitoring code at runtime.
Notes
- CRA uses webpack under the hood. The package is tree-shakeable and adds minimal bundle size when included.
- No
ejector custom webpack config is needed. - If you use Axios, follow Axios Integration to track those requests.