Nuxt: window/document/localStorage is not defined (SSR) Vue Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

Nuxt: ReferenceError: window is not defined / 500 Internal Server Error during SSR

Code touching browser globals ran on the server during Nuxt SSR.

Exact message you may see 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
Seen on: Vue Node.js

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/document in setup or module top-level
  • Library accessing browser APIs on import
  • Plugin running on server
  • localStorage in store initialisation
  • Charts/editors/maps

⚡ Quick fix

  1. if (import.meta.client) { ... } or onMounted
  2. <ClientOnly> around browser-only components
  3. Name plugin foo.client.ts

Detailed fix by platform

Nuxt

  1. onMounted(() => { const w = window.innerWidth; });

How to diagnose

  1. Where — setup/top-level?
  2. Guard — import.meta.client?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

[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 (Vue)[Vue warn]: Hydration…Hydration failed — Error: Hydration failed because the initial UI does not match what was rendered on the server (React)Hydration failedNuxt 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 (Vue)Nuxt 404: Page not fo…Nuxt: Failed to fetch dynamically imported module (after deploy) — Nuxt: [nuxt] error caught during app initialization TypeError: Failed to fetch dynamically imported module / Loading chunk failed (Vue)Nuxt: Failed to fetch…Nuxt: Hydration completed but contained mismatches — Nuxt: [Vue warn]: Hydration completed but contains mismatches. (Vue)Nuxt: Hydration compl…Nuxt/Vite: Failed to resolve import "~/..." or "@/..." — Nuxt: [vite] Internal server error: Failed to resolve import "~/components/Foo.vue" from "pages/index.vue". Does the file exist? (Vue)Nuxt/Vite: Failed to …Prop did not match — Warning: Prop `className` did not match. Server: "x" Client: "y" (React)Prop did not matchReferenceError: document is not defined — Next.js: ReferenceError: document is not defined (Next.js)ReferenceError: docum…Nuxt: win…

Explore the map of this error Full error map →

🧠 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.