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. 1. Use the official Next.js package

    1. Install @posthog/next
    2. Add PostHogProvider and PostHogPageView to the root layout
    3. Note that bootstrapFlags makes the route dynamic, which is incompatible with static generation and ISR
  2. 2. Capture pageviews manually

    1. Set capture_pageview: false in posthog.init()
    2. Create a client component that reads usePathname() and useSearchParams() and calls posthog.capture('$pageview') in an effect
    3. Wrap it in <Suspense> and mount it once in the root layout
  3. 3. Rule out blocking

    1. Add a Next.js rewrite for /ingest to your PostHog region host and set api_host to /ingest
    2. 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