Menu

"PostHog + Next.js 16 App Router: the Suspense gotcha that silenced my analytics for 6 days"
📰
0

"PostHog + Next.js 16 App Router: the Suspense gotcha that silenced my analytics for 6 days"

DEV Community·Diven Rastdus·about 1 month ago
#Xtbh5Fsb
#gotcha#how#nextjs#posthog#fullscreen#react
Reading 0:00
15s threshold

I shipped a no-op stub of PostHogProvider.tsx on April 20. I told myself I would come back to it that afternoon. Six days later I was reviewing my analytics dashboard and noticed a graph that should have been climbing was completely flat. Every posthog.capture() in my Next.js 16 App Router app had been firing into a black hole. Including the one event I actually cared about: the waitlist signup. This is the post-mortem. Three gotchas, real code, and how I verified the fix in a way that did not depend on trusting the PostHog dashboard. How I broke it The original component looked roughly like this: " use client " ; import posthog from " posthog-js " ; export default function PostHogProvider ({ children }: { children : React . ReactNode }) { if ( typeof window !== " undefined " ) { posthog . init ( process . env . NEXT_PUBLIC_POSTHOG_KEY ! , { api_host : " https://us.i.posthog.com " , }); } return <> { children } </>; } Enter fullscreen mode Exit fullscreen mode Looks fine, builds fine, ships fine.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More