💡 Minimize the page or switch tab then return

useDocumentVisibility

Reactively track document.visibilityState

Usage

import { useDocumentVisibility } from '@vueuse/core'

const visibility = useDocumentVisibility()

Type Declarations

/**
 * Reactively track `document.visibilityState`.
 *
 * @see   {@link /useDocumentVisibility}
 * @param options
 */
export declare function useDocumentVisibility({
  document,
}?: ConfigurableDocument): Ref<VisibilityState>

Source

SourceDemoDocs