Skip to content

react-visibility-hooks

Zero-dependency React hooks for visibility, idle detection, smart polling, battery, wake lock, and more. Tree-shakeable, SSR-safe, TypeScript-first.

Why react-visibility-hooks?

Zero Dependencies

No runtime dependencies. Ship less JavaScript to your users.

SSR-Safe

Works with Next.js (App & Pages Router), Remix, Gatsby, and all SSR frameworks out of the box.

Tree-Shakeable

Import only the hooks you need — unused hooks are automatically excluded from your bundle.

TypeScript-First

Fully typed with exported interfaces. Great autocomplete and compile-time safety.

The Hooks

HookDescription
useDocVisibleIs the browser tab visible?
useIdleVisibilityPage visibility + user idle detection
useAutoPauseVideoAuto-pause/resume <video> on tab visibility
useSmartPollingVisibility-aware data polling with dedup
usePageFocusEffectCallbacks on visibility transitions
useNetworkAwarePollingSmart polling + network quality awareness
useInactivityTimeoutSession timeout with warning countdown
useWakeLockPrevent screen dimming
useBatteryAwareReact to device battery level and charging state