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.

Server-side rendering: "ReferenceError: navigator is not defined"

See original GitHub issue

When I include this module in one of my views that I render on the server (using React here), I get the ReferenceError mentioned in the subject. Regardless of the fact that I’m not calling .setup() or any braintree methods on the server, Node parses the module and breaks on the navigator references.

I’m not able to offer a pull request on the minified code in this repo, but a cursory look at it tells me the server may break on the unchecked references to window and document.

My current workaround is including the library in the <script> tags in my html, and not in my overall Webpack build. This is unfortunate as it increases the number of requests each page must do.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
EvanHahncommented, Jun 17, 2016

While execution of this library is still only supported in browser environments, the latest beta of the new version of our SDK (braintree-web@3.0.0-beta.9) can be required in Node which may help with server-side rendering.

Here are some links to our official documentation:

3reactions
jaredpalmercommented, Mar 25, 2016

Oh sorry, I forgot that I disgustingly added it with just a script tag in my html template. Ugly, but it’s the only way to get it work with react and SSR

Read more comments on GitHub >

github_iconTop Results From Across the Web

navigator is not defined in angular4 with server side rendering ...
I am using simpleMDE editor with my angular 4 Server side rendering application and getting the reference of textarea using
Read more >
Server Side Rendered React throws `navigator is not defined`
Running locally the scheduler works as expected but when deployed the schedulers breaks the application with the following log output:.
Read more >
next js navigator is not defined - You.com | The AI Search ...
Probably this package is not suitable for SSR. It seems like it calls navigator without checking availability of the browser api and it...
Read more >
How to solve Next.js window is not defined
An easy solution to resolve this issue is to rely on the useEffect , conveniently hooks aren't run when doing server-side rendering. Wrapping ......
Read more >
Node.js – Fixing “ReferenceError: navigator is not defined”
If you're doing server side rendering then you need to call navigator in a function that is run on the client side. For...
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