useVisibilityChange

Track document visibility and respond to changes with useVisibilityChange.

Install:

npm i @uidotdev/usehooks

Description:

The useVisibilityChange hook is useful for tracking the visibility state of a document or web page. It allows you to easily detect when the document is visible or hidden, and perform certain actions based on that information. The hook returns a boolean value indicating whether the document is currently visible or not, allowing components to react accordingly and update their rendering or behavior based on the visibility state.

Return Value

NameTypeDescription
documentVisiblebooleantrue if the document is currently visible, false otherwise.

Demo:

Example:

More Hooks:

Sort: