Skip to content

DevHUD

The main wrapper component that enables performance monitoring. Renders a floating HUD overlay in development and passes children through unchanged in production.

Import

tsx
import { DevHUD } from "react-performance-monitoring"

Usage

tsx
<DevHUD>
  <App />
</DevHUD>

Props

PropTypeDefaultRequiredDescription
childrenReactNodeYesYour app or root component
position"top-left" | "top-right" | "bottom-left" | "bottom-right""top-right"NoHUD overlay position
theme"light" | "dark""dark"NoVisual theme
trackNetworkbooleantrueNoEnable network tracking (fetch + optional axios)
trackLongTasksbooleantrueNoEnable long-task monitoring
trackFPSbooleantrueNoEnable FPS sampling
sessionTimeoutnumber2000NoInactivity timeout (ms) before session closes
forceEnabledbooleanfalseNoShow HUD regardless of NODE_ENV. Use for deployed demos/previews.

Behavior

  • Collapsible: Click × to fully collapse the panel; a small "RPM" tab remains to re-open it.
  • Repositionable: Use the corner icons in the panel header to move the HUD to any corner at runtime.
  • Dev-only: When NODE_ENV === "production" and forceEnabled is not set, DevHUD renders only children; no overlay or trackers are mounted.
  • SSR-safe: If window is undefined (e.g. during SSR), it behaves as in production.
  • Profiler wrapper: Children are wrapped in a React Profiler so render timings are captured.
  • Portal: The HUD is rendered via createPortal into a dedicated container ([data-rpm-root]) appended to document.body.

TypeScript

tsx
import type { DevHUDProps } from "react-performance-monitoring"