Currently, I am in the process of transitioning an enterprise application (unable to share code) from Create React App to NextJS using TypeScript.
Although I have successfully replaced React Router with Next Routes/Pages, I keep running into the same error message whenever I attempt to build the application:
An error occurred while prerendering page "/". For more information, please visit: https://nextjs.org/docs/messages/prerender-error
ReferenceError: window is not defined
I have gone through the code and made sure to wrap any instance of 'window' within an if check (
if(typeof window !== 'undefined')
). Despite this effort, the error persists.
Can anyone offer advice on how to locate all references to 'window' and ensure they comply with NextJS standards? Are there any potential pitfalls that others may have encountered?
I have gone through the code and made sure to wrap any instance of 'window' within an if check (
if(typeof window !== 'undefined')
). Nevertheless, the issue remains unsolved.