Skip to main content
This is the 5-minute integration walkthrough. Before you start, make sure you’ve completed Installation.

1. Install the plugin

The KontextAdsPlugin initializes a session that’s available to every component in your app via the useAds() composable.
If you’d rather scope a session to part of your component tree, use <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. Call addMessage() 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:
Every placement-attributed event (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.