Server-side rendering: "ReferenceError: navigator is not defined"
See original GitHub issueWhen 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:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 berequire
d in Node which may help with server-side rendering.Here are some links to our official documentation:
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