question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: window is not defined in Server side rendering

See original GitHub issue

Hi Using the library, When try to build the application, which has both server side rendering as well as client side rendering, got the following issue.

…\node_modules\react-router-last-location\dist\index.js:10 [1] })(window, function(WEBPACK_EXTERNAL_MODULE__0, WEBPACK_EXTERNAL_MODULE__1, WEBPACK_EXTERNAL_MODULE__6) { [1] ^ [1] ReferenceError: window is not defined

Kindly add the following check in index.js => typeof window != "undefined" ? window : ''

So that it will work without any issues in ssr based application.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sasiganthcommented, May 17, 2019

@hinok Have verified, now it’s working fine. Thanks for the immediate fix.

1reaction
hinokcommented, May 16, 2019

I will release fixed version today evening (my local time - Warsaw, PL).

Read more comments on GitHub >

github_iconTop Results From Across the Web

React JS Server side issue - window not found - Stack Overflow
BROWSER to my advantage because it will be defined as undefined if it is server side, and it will be true if the...
Read more >
How to solve Next.js window is not defined
Solve a the common ReferenceError: next.js window is not defined error that you may see when doing SSR & pre-rendering.
Read more >
How to solve "window is not defined" errors in React and Next.js
Because in the Node.js world, window is not defined, window is only available in browsers. There are three ways to solve that: 1....
Read more >
Using window in React SSR: The Complete Guide
window is not defined on the server, so you can't use it during the render of a component being SSR'd. ... During a...
Read more >
referenceerror: window is not defined, how to solve
Here's how to fix the “referenceerror: window is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found