Vue · VUE0011
Do not read browser APIs in SSR setup paths
Flags browser API in setup in Vue SSR code before it leaks into runtime behavior.
vue/ssr/no-browser-api-in-setupsrc/rule-packs/vue/rules/vue/no-browser-api-in-setup.ts Upstream docs Run this rule
pnpm vite-doctor . --framework vue --rules vue/ssr/no-browser-api-in-setup
Why it matters
Server-rendered markup must match the first client render. Browser-only state, time, randomness, or hash-sensitive URLs can create hydration mismatches.
Recommended fix
Remove browser API in setup, or move it to the Vue runtime/API that owns that behavior.
Useful links
Example
Move browser API usage to mounted
Before
<script setup lang="ts">
const width = window.innerWidth
</script>
After
<script setup lang="ts">
const width = ref(0)
onMounted(() => { width.value = window.innerWidth })
</script>