BannerAd
import { BannerAd, type BannerAdProps } from 'nitro-ui-admob'
function BannerAd(props: BannerAdProps): ReactElement
A banner ad. Fixed sizes lay out at their ad size; anchoredAdaptive takes its laid-out width and reports its height. Layout props override the size-derived width and height. Guide: banner ads.
Props
BannerAdProps extends NitroUI's SharedViewProps without children, so layout and the other shared view props apply.
| Prop | Type | Description |
|---|---|---|
adUnitId | string | Required. The AdMob ad unit ID. An empty string loads nothing. |
size | BannerAdSize | Defaults to anchoredAdaptive, which uses the laid-out width. |
requestOptions | AdmobRequestOptions | Targeting for the ad requests. Changing its contents loads a new ad. |
onAdLoaded | (dimensions: BannerAdDimensions) => void | An ad loaded, with its size. |
onAdFailedToLoad | (error: AdmobError) => void | An ad request failed. |
onAdImpression | () => void | The SDK recorded an impression. |
onAdClicked | () => void | The SDK recorded a click. |
onAdPaid | (value: AdmobAdValue) => void | With the estimated revenue of an impression. |
onAdOpened | () => void | The ad opened an overlay over the app. |
onAdClosed | () => void | The overlay opened by the ad was dismissed. |
onSizeChange | (dimensions: BannerAdDimensions) => void | With the ad size before each request. |
Types: BannerAdDimensions, AdmobError, AdmobAdValue.
BannerAdView
import type { BannerAdView } from 'nitro-ui-admob'
The native view behind BannerAd, exported as a type. It loads an ad once adUnitId is set and, for adaptive sizes, laid out. It has the props above as properties, and:
| Member | Description |
|---|---|
destroy() | Stops ad requests, drops all callbacks and releases the native banner. The view stays mountable. BannerAd calls it on unmount. |