VibeDict

🧩Browser features used on the server (window is not defined)

What you'll see
ReferenceError: window is not defined (또는 document / localStorage is not defined)

This error happens when window, document, or localStorage, which only exist in the browser, are run on the server.

🤔 Why does it happen?

  • Frameworks like Next.js draw pages on the server first, and browser features were used at that time
  • A browser-only library was imported right at the top

🔧 Try this

  1. Use browser features only inside useEffect or inside events
  2. Load browser-only libraries only in the browser (dynamic import, ssr turned off)

🤖 Ask your AI like this

I get the 'window is not defined' error below. Please find where browser features are used and fix it so they only run in the browser. [Paste the full error here]

Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.

Related terms

Other errors in this group