Skip to content
R

React Page Visibility

Declarative, nested, stateful, isomorphic page visibility React component

by pgiladFree

#4686in Developer Tools
0In stores

Description

react-page-visibility is a React component that wraps the browser's Page Visibility API, so your app knows when its tab is hidden or visible…

Highlights

  • Declarative page visibility for React
  • Higher-order component that can be nested
  • usePageVisibility hook
  • onChange callback and render-prop children
  • Cross-browser support with a safe fallback

Ratings & Reviews

No ratings yet

Be the first to rate React Page Visibility.

People also visit

R

react-on-screen

A wrapper component to track if your react component is visible on screen

UI Libraries
Launch
R

react-visibility-sensor

Sensor component for React that notifies you

UI Libraries
Launch
R

react-scroll

React scroll component

UI Libraries
Launch
R

react-headroom

Hide your header until you need it. React.js port of headroom.js

UI Libraries
Launch
R

react-smooth-collapse

React component for animating showing or hiding an element

UI Libraries
Launch
R

@rc-component/portal

React Portal Component

UI Libraries
Launch

React Page Visibility FAQ

What does react-page-visibility do?

It tells a React component when the browser tab is hidden or visible, using the Page Visibility API.

Why use it instead of a helper function?

The README says the component manages the event listeners and the browser support checks for you.

How do I use it in a function component?

Use the usePageVisibility hook, as shown in the README.

Does it work in older browsers?

The README says it supports cross-browser use, including Internet Explorer and Safari, and falls back safely when the API is missing.

What is it useful for?

Pausing polling or animations while the page is in the background, to save bandwidth and processing.

Developer Stuff

Badges