diff --git a/src/features/core/hooks/use-visual-viewport-size.ts b/src/features/core/hooks/use-visual-viewport-size.ts index 98584e6..dfc3a94 100644 --- a/src/features/core/hooks/use-visual-viewport-size.ts +++ b/src/features/core/hooks/use-visual-viewport-size.ts @@ -5,11 +5,13 @@ const eventListerOptions = { }; const useVisualViewportSize = () => { - const windowExists = typeof window !== 'undefined'; + // Starts at zero on server and client alike, filling in after mount — the + // same contract as Mantine's useViewportSize. Reading window during render + // makes the client's first render disagree with the SSR markup. const [windowSize, setWindowSize] = useState({ - width: windowExists ? window.visualViewport?.width || 0 : 0, - height: windowExists ? window.visualViewport?.height || 0 : 0, - top: windowExists ? window.visualViewport?.offsetTop || 0 : 0, + width: 0, + height: 0, + top: 0, }); const rafRef = useRef(null);