<AdkitProvider />
Initializes the Adkit SDK and provides shared context to all AdSlot components in your tree.
Overview
AdkitProvider must wrap any part of your component tree that contains AdSlot components. Place it as high in the tree as possible — typically at the root of your app — so all slots share the same context and the refresh() API from useAdkit() works across your entire application.
AdkitProvider is marked "use client" internally. In Next.js App Router you do not need to add "use client" to the file that imports it — the directive is already inside the package.Props
| Prop | Type | Required | Description |
|---|---|---|---|
| siteId | string | Yes | Your Adkit site ID from the publisher dashboard |
| children | ReactNode | Yes | Your application tree |
React (Vite / CRA)
Wrap your root component and import the stylesheet. The stylesheet is required for slots to render correctly.
Next.js — App Router
Add the provider to your root layout. You do not need to create a separate client component wrapper — the package handles the "use client" boundary internally.
Next.js — Pages Router
Add the provider to your custom _app.tsx.
Context values
The provider exposes these values through the useAdkit() hook. You typically only need refresh().
| Value | Type | Description |
|---|---|---|
| siteId | string | The site ID passed to the provider |
| refreshKey | number | Increments each time refresh() is called; used by slots to remount |
| refresh | () => void | Clears all slot tracking and forces every slot to re-initialize (use after SPA navigation) |
| mountedSlots | Set<string> | Set of slot identities currently mounted (siteId:slot) |
| registerSlot | (identity: string) => boolean | Internal — used by AdSlot to detect duplicates |
| unregisterSlot | (identity: string) => void | Internal — used by AdSlot on unmount |
Rules
- Only one
AdkitProvidershould exist in your application at a time. - All
AdSlotcomponents must be descendants of the provider, unless you passsiteIddirectly to the slot. - The
refresh()API fromuseAdkit()only works inside the provider tree.