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.
VUE0011vite-doctor/vuessrerrorSuggestion

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.

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

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