useDocumentVisibilityState

About

Returns the visibility state of the document. Returns null on the server.

Examples

import {useEffect} from 'react'
import {useDocumentVisibilityState} from "rooks"
export default function App() {
const isDocumentVisible = useDocumentVisibilityState();
useEffect(() => {
console.log(isDocumentVisible)
}, [isDocumentVisible])
return <p>Try switching to a different tab and check console </p>
}

Join the community!

Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!

Powered by vercel