1. Install the plugin
TheKontextAdsPlugin initializes a session that’s available to every component in your app via the useAds() composable.
<AdsProvider> instead — it accepts the same options as the plugin.
2. Feed messages to the SDK
The SDK preloads ads in response to new chat messages. CalladdMessage() from the useAds() composable whenever a user or assistant message is created.
3. Mount <InlineAd>
An ad slot is a designated area in your UI where an ad can be rendered. In most cases, it appears below an assistant message.
Place <InlineAd /> wherever the ad should appear and pass the messageId of the assistant message it’s associated with.
Observing events
Subscribe to ad lifecycle events via the plugin or<AdsProvider> onEvent prop. Every event has a stable name and a typed payload:
ad.filled, ad.viewed, ad.clicked, ad.render-*, video.*, reward.granted) also carries a top-level code field naming the matched placement, so publishers with multiple enabledPlacementCodes can disambiguate. Session-wide events (ad.no-fill, ad.error) omit it.
For SDK-internal diagnostics during integration, also pass an onDebugEvent callback — it receives (name, data?) for every internal step.