Next.js
Clearlook in a Next.js app (App Router or Pages Router).
- App Router: the tag goes in
app/layout.tsx, inside<head>, as a plain<script defer …>element ornext/scriptwithstrategy="afterInteractive". Route changes are recorded by the script; no router hook is needed. - Pages Router: the tag goes in
pages/_document.tsxinside<Head>. - npm: the package isn't on npm yet; use the tag.
- Keys:
NEXT_PUBLIC_PLATFORM_KEYholds thepk_key. Server-only keys never get theNEXT_PUBLIC_prefix. - Users: in the client component that knows the signed-in user:
platform.setConsent('granted'), thenplatform.identify(user.id). - Errors:
@sentry/nextjswith the project DSN; source maps upload in CI (errors-sourcemaps). - Pitfall: a Content-Security-Policy in
next.configor middleware needshttps://app.clearlook.devinscript-srcandconnect-src.