use-document-visibility
Detects if the current tab is active
Source
Docs
PackageIcon
Usage
The use-document-visibility hook returns the current document.visibilityState
– it allows you to detect if the current tab is active:
Switch to another tab to see document title change