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