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

Amplitude SDK integration with NextJS Pages Router #710

Open
piyushchauhan2011 opened this issue Apr 10, 2024 · 2 comments · May be fixed by #721
Open

Amplitude SDK integration with NextJS Pages Router #710

piyushchauhan2011 opened this issue Apr 10, 2024 · 2 comments · May be fixed by #721
Labels
bug Something isn't working

Comments

@piyushchauhan2011
Copy link

piyushchauhan2011 commented Apr 10, 2024

Getting error while integration of Next.js pages router and amplitude sdk
Followed the instructions as mentioned in examples: https://github.com/amplitude/Amplitude-TypeScript/blob/main/examples/browser/next-app/pages/_app.tsx#L22

Expected Behavior

No error during build

Current Behavior

Amplitude Logger [Warn]: Event not tracked, no destination plugins on the instance
   Collecting page data  ...ReferenceError: navigator is not defined
at Object.<anonymous> (/app/node_modules/.pnpm/@amplitude+analytics-browser@2.6.2/node_modules/@amplitude/analytics-browser/lib/cjs/plugins/network-connectivity-checker.js:31:31)

Possible Solution

Seems like it doesn't work with server, not sure any possible fix from my side

Steps to Reproduce

  1. create blank nextjs app
  2. pnpm add @amplitude/analytics-browser
  3. add the integration as mentioned: https://github.com/amplitude/Amplitude-TypeScript/blob/main/examples/browser/next-app/pages/_app.tsx#L22
  4. Build results in given error

Environment

  • JS SDK Version: 2.6.2
  • Installation Method: pnpm
  • Browser and Version: Chrome 123 latest
@piyushchauhan2011 piyushchauhan2011 added the bug Something isn't working label Apr 10, 2024
@piyushchauhan2011
Copy link
Author

For now I used useEffect but I think it calls .init multiple times, which seems incorrect.

@mithRabbit
Copy link

same issue happened with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants