Nuxt · Hydration & SSR

NUXT0072Use useWindowSize for reactive viewport size

Finds VueUse project code that should use the supported useWindow size pattern instead.

Why it happens

Reading window dimensions directly misses later resizes unless the component owns listener setup and cleanup; useWindowSize() maintains reactive dimensions.

Fix

Use VueUse useWindowSize() instead of reading window dimensions by hand.

Example

Use VueUse window size

Before

<script setup lang="ts">
const width = ref(window.innerWidth)
window.addEventListener('resize', () => { width.value = window.innerWidth })
</script>

After

<script setup lang="ts">
const { width } = useWindowSize()
</script>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm nuxt doctor --rules vueuse/prefer-usewindow-size
Copyright © 2026