Nuxt · Hydration & SSR

NUXT0030Avoid browser side effects in universal setup

Flags browser side effects in setup in Nuxt hydration code before it leaks into runtime behavior.

Why it happens

Server-rendered markup must match the first client render. Browser-only state, time, randomness, or hash-sensitive URLs can create hydration mismatches.

Fix

Remove browser side effects in setup, or move it to the Nuxt runtime/API that owns that behavior.

Example

Move browser side effects out of setup

Before

<script setup lang="ts">
localStorage.setItem('seen', '1')
</script>

After

<script setup lang="ts">
onMounted(() => {
  localStorage.setItem('seen', '1')
})
</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 nuxt/hydration/no-browser-side-effects-in-setup
Copyright © 2026