Component
AdsenseScript
Next.js Script component that injects the Google AdSense snippet. Respects cookie consent — the script is only loaded after the user accepts analytics cookies.
Usage — place in root layout
live editor — edit to update preview
// app/layout.tsx import { AdsenseScript } from "@ann/ui"; export default function RootLayout({ children }) { return ( <html> <body> <AdsenseScript /> {children} </body> </html> ); }
Notes
- No props — the AdSense client ID is read from the
NEXT_PUBLIC_ADSENSE_IDenvironment variable. - Depends on
CookieConsentbeing mounted somewhere in the tree. The script waits for consent before loading. - Next.js only — uses the
next/scriptafterInteractivestrategy.
Props
| Prop | Type | Default | Description |
|---|