Nuxt · Browser APIs

NUXT0071Use useEventListener for DOM events

Finds VueUse project code that should use the supported useEvent listener pattern instead.

Why it happens

Effects that outlive their component create leaks and stale updates. Register cleanup where Vue or VueUse can dispose it automatically.

Fix

Use VueUse useEventListener() so the listener is removed with the component scope.

Example

Use VueUse event listeners

Before

<script setup lang="ts">
onMounted(() => window.addEventListener('resize', onResize))
onBeforeUnmount(() => window.removeEventListener('resize', onResize))
</script>

After

<script setup lang="ts">
useEventListener(window, 'resize', onResize)
</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-useevent-listener
Copyright © 2026