Frameworks and SPAs
Pertento for Next.js
Render the tag in the root layout so it loads before hydration, and variants persist across client-side route changes.
One script tag · 0.9 KB · no cookiesAll integrations
In a Next.js application the tag belongs in the root layout, emitted into the document head so it runs before the framework hydrates. Once it has, variants survive client-side navigation: the visitor moving between routes keeps the version they were assigned, without the tag being re-run or the change being reapplied. For experiments that change what the server renders rather than what the browser sees, the SDK is called during the request instead.
How it connects
- Emit the tag from the root layout’s head, loaded synchronously rather than deferred.
- Leave client-side routing alone. Assignment persists across it on its own.
- Use the SDK inside server-rendered routes when the variant changes the markup that ships.
More in Frameworks and SPAs
All integrations