For the complete documentation index, see llms.txt. This page is also available as Markdown.

Ad Monetization API

Monetize your game with rewarded videos and interstitials. The host manages presentation; your game just requests placements and reacts to the result.

This is ad monetization — earning revenue by showing ads inside your game. To spend on ads that bring new players to your game, see Marketing Your Game.

On desktop and mobile web, capabilities.ads is false. isRewardedAdReadyAsync() and isInterstitialAdReadyAsync() resolve false, showRewardedAdAsync() resolves with no reward, and showInterstitialAd() resolves without showing anything. No ad or download prompt appears. Hide ad-dependent controls when capabilities.ads is false.

Ad Types

Rewarded Video Ads

Opt-in ads where players receive rewards for watching. Players choose to watch these ads in exchange for in-game benefits.

const isReady = await RundotGameAPI.ads.isRewardedAdReadyAsync()
if (isReady) {
  const rewardEarned = await RundotGameAPI.ads.showRewardedAdAsync()
  if (rewardEarned) {
    grantReward() // Player earned the reward
  }
}

showRewardedAdAsync() resolves true only when the reward was actually earned. A false result covers both "the ad was never shown" and "the ad was shown but the player closed it early". Treat the boolean as your grant gate, not as a "the ad played" signal. The host does not surface a separate "shown" flag for rewarded ads. Note that there is no guarantee of durable reward receipt or recovery in cases of native OS force-close, process termination, or unexpected app exit while an ad is active.

Use cases:

  • Extra lives or continues

  • Bonus currency

  • Speed up timers

  • Unlock temporary power-ups

Interstitial Ads

Forced ads that interrupt gameplay at natural break points. These ads are automatically hidden for platform subscribers.

Use cases:

  • Between levels

  • After game over

  • After completing a session

  • On menu transitions

Note: Interstitial ads are hidden for users with platform subscriptions. Your code can safely call showInterstitialAd() for all users: subscribers simply won't see the ad.

Quick Start

Complete Example

API Reference

Recovery when an ad fails

Ad requests must not block gameplay indefinitely. The host owns ad time limits. The SDK waits for the host's answer. On a transport error, the SDK returns false and sends a recovery request. A recovery request carries its cause and time. The host ends a displayed ad only on a tap after display. A timer never grants a reward. Host recovery preserves a reward that the host already received.

On Android and iOS, a return to the app does not end an ad, because the ad can still be on screen. A tap in the game after display does. After a recovery, the host disables further native ads for that app session. This recovery does not confirm that the native ad screen closed.

Continue the game after either result. Release any game-owned ad wait in finally. Keep deliberate menu pauses separate from ad waits. Use lifecycle notifications to control the game loop. Do not require a successful ad result to remove an ad loading screen.

These changes require an updated host and SDK. JavaScript recovery cannot close a broken native ad screen or restore a reward after process termination.

Method
Returns
Description

isRewardedAdReadyAsync()

Promise<boolean>

Check if a rewarded ad is available

isInterstitialAdReadyAsync()

Promise<boolean>

Check if an interstitial ad is available

showRewardedAdAsync(options?)

Promise<boolean>

Show rewarded ad; resolves true when the reward was earned

showInterstitialAd(options?)

Promise<boolean>

Show interstitial ad; resolves true if the ad was displayed (e.g. false for subscribers or when no ad was available)

Display Options

Both showRewardedAdAsync(options?) and showInterstitialAd(options?) accept an optional options object. Every field is optional; the object is forwarded to the host for placement attribution and analytics. Omit it and the host uses its defaults.

Field
Type
Required
Default
Description

adDisplayId

string

No

-

Identifier for this ad placement (e.g. 'extra_life', 'level_transition'). Used by the host for attribution.

adDisplayName

string

No

-

Human-readable name for the placement, surfaced alongside adDisplayId in analytics.

Deprecated top-level aliases

Older code may call RundotGameAPI.isRewardedAdReadyAsync() and RundotGameAPI.showRewardedAdAsync() directly on the root object. Both still work and forward to the ads namespace, but they are marked @deprecated; use the ads namespace in new code.

The top-level RundotGameAPI.showRewardedAdAsync() takes no arguments: it cannot pass adDisplayId / adDisplayName, so you lose placement attribution. Use RundotGameAPI.ads.showRewardedAdAsync(options?) to keep it.

Deprecated
Use instead

RundotGameAPI.isRewardedAdReadyAsync()

RundotGameAPI.ads.isRewardedAdReadyAsync()

RundotGameAPI.showRewardedAdAsync()

RundotGameAPI.ads.showRewardedAdAsync(options?)

Best Practices

  • Preflight with isRewardedAdReadyAsync() / isInterstitialAdReadyAsync() before calling display methods: hosts may throttle requests during campaigns.

  • Disable reward buttons when isRewardedAdReadyAsync() returns false to avoid extra clicks.

  • Guard reward logic so you only grant the prize when the call resolves true.

  • Wrap ad calls in try/catch and fail silently; players might deny permissions or lose connectivity.

  • Show interstitials at natural break points (level transitions, game over) not mid-gameplay.

  • Don't show interstitials too frequently: player experience matters.

Last updated