How to integrate PostHog with GDPR-compliant consent in Next.js using c15t
Developers building EU-facing Next.js applications can use the open-source c15t library to ensure PostHog analytics only loads after a user grants measurement consent. The c15t PostHog script helper manages the full script lifecycle — including loading, consent updates, revocation, and script removal — replacing the need to call posthog.init() directly. Three loading modes are available: after-consent, always, and disabled, with after-consent recommended for strict GDPR compliance as it blocks any PostHog network request until consent is given. The integration is configured via the ConsentManagerProvider in a Next.js App Router project after installing the @c15t/nextjs and @c15t/scripts packages. The guide also covers cookieless tracking as an alternative and advises developers to seek legal counsel before deploying consent flows in production.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in