PostHog Pageviews Missing or Duplicated in Next.js
Workaround available Web (Next.js, React, SPAs) Updated October 21, 2026
Quick answer
In the Next.js App Router and other SPAs, client-side navigation doesn't reload the page, so pageviews are missed or double counted. Set capture_pageview to false and capture $pageview on route change, or use the official @posthog/next package.
Most likely fix: Use the official Next.js package.
Symptoms
Only the first page of each visit is tracked, or every page shows two $pageview events.
Why it happens
- Automatic pageview capture plus a manual pageview component both firing
- Pageview component mounted twice
- Route changes not triggering a capture
- Events blocked by ad blockers or sent to the wrong region host
How to fix it
Try these in order — the most common fix is first.
1. Use the official Next.js package
- Install @posthog/next
- Add PostHogProvider and PostHogPageView to the root layout
- Note that bootstrapFlags makes the route dynamic, which is incompatible with static generation and ISR
2. Capture pageviews manually
- Set capture_pageview: false in posthog.init()
- Create a client component that reads usePathname() and useSearchParams() and calls posthog.capture('$pageview') in an effect
- Wrap it in <Suspense> and mount it once in the root layout
3. Rule out blocking
- Add a Next.js rewrite for /ingest to your PostHog region host and set api_host to /ingest
- Confirm the region (US or EU) matches your project
This guide also covers
- posthog nextjs pageview
- posthog duplicate pageviews
- posthog app router pageview
- posthog spa pageview not tracked
- posthog capture_pageview
Still not working?
If PostHog keeps failing, you're not alone. See every PostHog problem users report or the alternatives people switch to.
Other PostHog errors
- PostHog Events Not Showing Up
- PostHog Blocked by Ad Blockers
- PostHog Session Replay Not Recording
- PostHog Replay Broken: Missing CSS, Fonts or Blank Screen
- PostHog Bill Too High
- PostHog Feature Flags Not Working or Undefined
- PostHog Numbers Different From Google Analytics
- PostHog Identify Merging Wrong Users
- PostHog Surveys Not Showing
- PostHog Toolbar or Heatmaps Not Loading
- Why Is PostHog So Slow?
- PostHog Not Capturing Events in Playwright or Puppeteer Tests