use-document-visibility

Detect if current tab is active

Usage

use-document-visibility hook returns current document.visibilityState – it allows to detect if current tab is active:

Switch to another tab to see document title change

Definition

function useDocumentVisibility(): "visible" | "hidden";