Installation
App Router (Next.js 13+)
1
Create an AdSlot component
The SDK manipulates the DOM, so it must run on the client. Create a reusable
AdSlot component:2
Add your Site ID to the environment
3
Use the component in any Server or Client component
Pages Router (Next.js 12 and below)
1
Create the AdSlot component
Same component as above — the
'use client' directive is ignored in the Pages Router and has no effect.2
Initialize once in _app.tsx
3
Place slots on any page
SPA route changes (App Router)
The App Router handles client-side navigation automatically. If you notice ads not refreshing after navigation, reset the singleton on route changes using theusePathname hook:
layout.tsx:
TypeScript types
Environment variables
Because it is prefixed with
NEXT_PUBLIC_, it is exposed to the browser. This is intentional — the Site ID is not a secret.
Full configuration options
Troubleshooting
→ Full troubleshooting guide