SDKsReact Native

Reference

Props for the Koah React Native ad components.

Component props

The three ad components share most props. adContext (required on the text and feed components) takes a KoahAdContext; cacheKey is a stable per-slot id; chrome toggles the card background/border/padding; sizing uses per-axis width / height of type KoahAxisSize β€” KoahAxisSize.fixed(dp), KoahAxisSize.range({ min, max }), or KoahAxisSize.fill(); omit an axis to hug the content.

Component Props

interface KoahTextAdComponentProps {
  // Required props
  adContext: KoahAdContext          // e.g. KoahAdContext.conversation({ question, answer })

  // Optional props
  cacheKey?: string                 // Stable key for the slot (default: random UUID per mount)
  width?: KoahAxisSize              // Horizontal sizing (omit to hug the content)
  height?: KoahAxisSize             // Vertical sizing (omit to hug the content)
  chrome?: "standard" | "bare"      // Card chrome (default: "standard")
  children?: ReactNode              // AI response component to wrap

  // Callbacks
  onEvent?: (event: KoahEvent) => void
}

Event handling

The onEvent callback notifies you of ad lifecycle events. KoahEvent is a discriminated union on kind:

KindWhen it fires
noAdFillAn ad request resolved with no ad
adServedAn ad request resolved with an ad
slotTooSmallThe card rendered nothing instead of clipping β€” a served ad couldn't fit the slot's bounds, or fill() was used on an axis the parent leaves unbounded
impressionTrackedThe ad became visible and the impression was recorded
adViewedThe ad stayed visible long enough to count as viewed
adClickedThe user tapped the ad
inAppBrowserClosedThe in-app browser opened from the ad was dismissed
import { KoahAdContext } from 'koah-react-native'

<KoahTextAdComponent
  adContext={KoahAdContext.conversation({ question, answer })}
  cacheKey={messageId}
  onEvent={(event) => {
    switch (event.kind) {
      case 'noAdFill':
        // no inventory for this request
        break
      case 'adServed':
        // ad delivered
        break
      case 'impressionTracked':
        // impression recorded
        break
      case 'adClicked':
        // user tapped the ad
        break
    }
  }}
/>

Theme properties

Set these on the theme prop of KoahThemeProvider.

PropertyTypeDefaultDescription
colorScheme"light" | "dark" | "auto""auto""auto" follows the device via React Native's useColorScheme()
accentColorstring"#0D0D0D"Accent for CTA buttons and accents. Text-on-accent is computed automatically for contrast β€” never expose it.
fontFamilystringundefined (inherits from host app)Font family applied to all ad text
cornerRadiusnumber19Card corner radius
Was this helpful?