{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-page-visible",
  "title": "usePageVisible",
  "description": "SSR-safe hook that reports whether the browser tab is visible, used to pause continuous animations.",
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "hooks/use-page-visible.ts",
      "content": "\"use client\"\n\nimport { useSyncExternalStore } from \"react\"\n\nfunction subscribe(onChange: () => void) {\n  document.addEventListener(\"visibilitychange\", onChange)\n  return () => {\n    document.removeEventListener(\"visibilitychange\", onChange)\n  }\n}\n\nconst getSnapshot = () => document.visibilityState === \"visible\"\nconst getServerSnapshot = () => true\n\n/** `true` while the browser tab is visible. Safe during SSR (assumes visible). */\nexport function usePageVisible() {\n  return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n}\n",
      "type": "registry:hook"
    }
  ],
  "meta": {
    "tier": "free",
    "collection": "interface",
    "needsImage": false,
    "addedAt": "2026-10-12",
    "tags": [
      "hook",
      "visibility"
    ],
    "tech": [],
    "presets": [],
    "keyboard": [],
    "heavy": false
  },
  "categories": [
    "internal"
  ],
  "type": "registry:hook"
}