Next.js: window is not defined during SSR component
The application works on customer navigation, but the page refresh ends with a window is not defined error. Window object does not exist in the server rendering environment; library import can perform the code immediately.
How to determine the source of the error
Check whether the window reads in the upper range of the module, while rendering or inside the library.
Locate the import after which the error begins, and check its SSR compatibility.
What to do step by step
1. Move a code requiring a window to the useEffect run in the browser or to a component loaded exclusively on the client side.
2 . If the library does not support SSR, separate its integration from the rest of the page and add a safe replacement view.
How to check the score
Direct opening and refresh of the page works without error; the browser function still works after hydration.
What to do
Do not use typeof window in random places if the import itself causes an exception earlier.