Skip to content

Hooks

All hooks must be used inside a component wrapped by DevHUD. Otherwise they throw.

usePerformanceMonitor

Returns the full context value: store, attachAxios, and isEnabled.

tsx
const { store, attachAxios, isEnabled } = usePerformanceMonitor()

Returns: PerformanceMonitorContextValue

PropertyTypeDescription
storePerformanceStorePub/sub store with getState, subscribe, etc.
attachAxios(instance) => () => voidAttach axios interceptors; returns teardown
isEnabledbooleanWhether monitoring is active (dev + browser)

usePerformanceState

Subscribes to the performance store and returns the current state. Re-renders when the store updates.

tsx
const state = usePerformanceState()

Returns: PerformanceStoreState

PropertyTypeDescription
sessionsPerformanceSession[]All recorded sessions
activeSessionIdstring | nullID of the current session
lastInteractionInteraction | nullMost recent interaction
latestRenderRenderEntry | nullMost recent render entry
latestNetworkNetworkEntry | nullMost recent network entry
latestLongTaskLongTaskEntry | nullMost recent long task
fpsFPSData | nullLatest FPS sample

usePerformanceSessions

Convenience hook that returns state.sessions.

tsx
const sessions = usePerformanceSessions()

Returns: PerformanceSession[]


useLatestInteraction

Convenience hook that returns state.lastInteraction.

tsx
const interaction = useLatestInteraction()

Returns: Interaction | null


useLatestFPS

Convenience hook that returns state.fps.

tsx
const fps = useLatestFPS()

Returns: FPSData | null


usePerformanceEnabled

Returns whether the monitor is enabled (dev mode + browser).

tsx
const enabled = usePerformanceEnabled()

Returns: boolean


useAttachAxios

Returns the attachAxios function for wiring axios instances.

tsx
const attachAxios = useAttachAxios()

useEffect(() => {
  const detach = attachAxios(axiosInstance)
  return () => detach()
}, [attachAxios])

Returns: (instance: AxiosLikeInstance) => () => void

See Axios Integration for usage details.