ReferenceError: window is not defined. This library does not work with SSR/SSG/Node env
It would be great if this library did not require window to exist. Otherwise this can't be used with a next.js app or be imported during SSG.
What would it take to check typeof window !== 'undefined' or something before referencing the window object? Or at least not reference window when the library is imported, and instead wait until some raygun function is invoked (lazy)?
Or is there another solution?
Thanks
Related: #301
Hi @TSMMark.
We're aware of the difficulties of using raygun4js with frameworks like Next.js and Remix, and we're considering how best to improve the UX for integrating Raygun with these frameworks.
In the meantime, we have documentation for integrating raygun4js for reporting clientside errors with Next.js.
We also have documentation for using raygun4node to report server-side errors using Next.js and Remix.
In future we may support both Node and the browser in a single library, but presently this is the best way to go, and also lets you utilise the full feature-set of each library.
Hi @TSMMark
If you have a look here https://raygun.com/documentation/language-guides/javascript/angular-two/#using-raygun-with-server-side-rendering
It shows how to use SSR/SSG in Angular. That may be another way of getting this to work for you.