Common Features
This document gathers the "common concepts" that were repeated across the individual ad type documents into one place to make maintenance easier, so that the ad type documents can focus on the features unique to each type.
๐งฑ Basic Structure & Common Call Pattern
Common Pattern for React / Next.js Provider
โ๏ธ Common Options Summary
| Option | Type | Description | Applies To |
|---|---|---|---|
onClick | function(adData) | Callback when the ad is clicked | All types |
adId | string | Force a specific ad | All types |
language | 'ko' | 'en' | 'ja' | 'zh' | Language filter | All types |
deviceType | 'MOBILE' | 'DESKTOP' | Device filter | All types |
country | Country code (ISO2) | Country filter | All types |
For options unique to each ad type, refer to the respective document (banner/text/video).
๐ Lifecycle & Internal Behavior
Key Characteristics
- Immediate-return type:
slotIdis returned immediately before the server responds โ no UI blocking - Handling of deferred containers: even if the container is not yet in the DOM, it will retry for a certain time and render once it is attached
- Automatic cleanup based on MutationObserver:
destroy()runs automatically when the DOM is removed - Multi-ad safe: when the same container is called repeatedly, only the latest call is valid (implementation policy)
๐งช Slot Management API
Slot object (actual fields):
๐ Common Performance & Optimization Strategies
| Strategy | Description | Notes |
|---|---|---|
| Background loading | No blocking of initial render thanks to async loading | slotId is usable immediately |
| Deferred container support | Automatically handles cases where the DOM is inserted later | Simplifies initialization code |
| Automatic cleanup | Prevents memory/event leaks | Useful during SPA transitions |
| Minimal DOM manipulation | Updates only the DOM inside the container | Minimizes impact on parent layout |
| Size optimization per type | Banner/video specify size, text uses automatic height | Reduces CLS |
Common Template for Responsive Pattern
๐ฆ Summary of Recommended React / Next.js Patterns
| Pattern | Description | When to Use |
|---|---|---|
| Global initialization via Provider | Configure the SDK only once | App/RootLayout |
| Hook (useAdStageInstance) | Safe SDK access | CSR component |
| cleanup in useEffect | Guarantees destroy | Clarifies slot lifetime |
| Skeleton style | Customize the .adstage-loading state | Improves UX |
๐จ Common CSS Classes
For additional styles per type, refer to the individual documents.
๐ Debugging & Monitoring
Enabling Debug Mode
Click Hook (onClick callback)
The SDK does not emit DOM CustomEvents such as adstage:ad:loaded / adstage:ad:error. If you need an ad interaction hook, pass an onClick callback when creating the slot.
Checking Load Status
You can check whether loading has completed by polling the slot's isLoaded field (if you turn on debug mode, load/failure is printed to the console).
State Diagnostic Utility
๐ Safety & Best Practices
| Topic | Recommendation |
|---|---|
| API Key | It can be publicly exposed, but use a key with minimal permissions |
| Event tracking | When adding tracking in onClick, sending asynchronously before routing is recommended |
| Error handling | Diagnose load failures using debug mode console logs and the slot's isLoaded state |
| Retry policy | The deferred container insertion case is handled internally โ avoid overusing additional setTimeout |
โFAQ (Common)
Q. Do I have to call destroy()?
A. In most cases, no. DOM removal detection is performed automatically. However, if you reuse the same container immediately for a different purpose, a manual destroy() is recommended.
Q. The ad isn't showing, but the slotId is returned.
A. It may still be loading asynchronously, or it may have been filtered out by a filter (adId / language / deviceType / country). Enable debug mode and check the event log.
Q. With SSR (Next.js), is it rendered on the server side?
A. No. Ad rendering is performed only on the client side. Call it inside a use client component.
Q. What happens with consecutive calls at the same location?
A. Per the implementation policy, the existing slot is removed and the state is maintained based on the last call.

