TipUse this hook to pause expensive operations—like WebSocket heartbeats, long-polling, or complex animations—when the user switches tabs to save battery and network resources.
Synchronizes with the document's visibility state (whether the tab is active/focused or hidden/minimized). It uses useSyncExternalStore for high-performance subscription to the visibilitychange event, making it ideal for pausing videos, stopping polling, or analytics.
| Name | Type | Description |
|---|---|---|
| isVisible | boolean | Derived boolean: true if visibilityState is 'visible'. |
| visibilityState | DocumentVisibilityState | The raw API value: 'visible', 'hidden', etc. |