Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: window is not defined. This library does not work with SSR/SSG/Node env #389

Open
TSMMark opened this issue Feb 4, 2021 · 2 comments

Comments

@TSMMark
Copy link

TSMMark commented Feb 4, 2021

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

@Widdershin
Copy link
Contributor

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.

@darcythomas
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants