import { useSyncExternalStore } from "react"; function subscribe() { // Document object doesn't change, but we need a subscription for the hook return () => {}; } function getSnapshot() { return typeof document !== "undefined" ? document : undefined; } function getServerSnapshot() { return undefined; } export function useDocument() { return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }