Nuxt: ReferenceError: window is not defined / 500 Internal Server Error during SSR
Code touching browser globals ran on the server during Nuxt SSR.
ReferenceError: window is not defined NuxtReferenceError: document is not defined NuxtReferenceError: localStorage is not defined Nuxt SSR[nuxt] [request error] ReferenceError: window is not definedNuxt 500 window is not defined Meaning
Run browser-only code in onMounted, guard with import.meta.client/process.client, wrap components in <ClientOnly>, or import libraries lazily (defineAsyncComponent, await import() inside onMounted). Plugins can be client-only (plugin.client.ts).
Common causes
window/documentin setup or module top-level- Library accessing browser APIs on import
- Plugin running on server
localStoragein store initialisation- Charts/editors/maps
⚡ Quick fix
if (import.meta.client) { ... }oronMounted<ClientOnly>around browser-only components- Name plugin
foo.client.ts
Detailed fix by platform
Nuxt
onMounted(() => { const w = window.innerWidth; });
How to diagnose
- Where — setup/top-level?
- Guard — import.meta.client?
- Library — Browser-only?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- [Vue warn]: Hydration node/text/children mismatch Vue: [Vue warn]: Hydration text content mismatch / Hydration node mismatch: server rendered element contains more child nodes than client vdom
- Hydration failed Error: Hydration failed because the initial UI does not match what was rendered on the server
- Nuxt 404: Page not found (route/file naming) Nuxt: 404 Page not found: /blog/my-post / [Vue Router warn]: No match found for location with path
Most viewed in Vue
- Property was accessed during render but is not defined Vue: [Vue warn]: Property "x" was accessed during render but is not defined on instance
- Failed to resolve component Vue: [Vue warn]: Failed to resolve component: x
- Avoid mutating a prop directly Vue: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026