Nuxt · NUXT0072

Use useWindowSize for reactive viewport size

Finds VueUse project code that should use the supported useWindow size pattern instead.
NUXT0072vite-doctor/vueusehydrationinfoSuggestion

Run this rule

pnpm nuxt doctor --rules vueuse/prefer-usewindow-size

Why it matters

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

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>
Copyright © 2026