Using Amplitude with SSR (React)
See original GitHub issueHi,
I am trying to migrate a codebase from client-side to server-side, and am using Amplitude like so:
import amplitude from 'amplitude-js/amplitude';
It is bundled by Webpack. On the server-side, I have this error:
document is not defined
, l.3020, called by global scope block l.3007
I’m a bit lost on this, as there is browser-specific code in global scope and therefore it can’t run on server…
Any insights?
Thanks in advance
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Using Amplitude with SSR (React) · Issue #110 - GitHub
Hi, I am trying to migrate a codebase from client-side to server-side, and am using Amplitude like so: import amplitude from ...
Read more >Server-side Rendering - Amplitude Developer Center
Use the Amplitude Experiment JavaScript Server SDK and JavaScript Client SDK together to create a seamless server-side rendered experience.
Read more >How to use Amplitude - Next Right Now
Amplitude is used to collect usage metrics (analytics) of the application. Amplitude is used only on the frontend part of the application. It...
Read more >How to use Server Side Rendering with React SDK?
Question React SDK doc states it works only on client side (browser). Is there a way to use it for SSR (Server Side...
Read more >How do integrate amplitude analytics with a React app?-Reactjs
You'll be able to turn on Amplitude via our dashboard, and have access to 250+ other destinations. Here is an example of using...
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 Free
Top 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
Hi,
Thanks for the answer. Indeed, I worked around it by doing:
For anyone interested by a real use case with Amplitude and Next.js 9 (universal app), check out https://github.com/UnlyEd/next-right-now
Interesting parts are: