Publishers · Getting started
Install the SDK
Add the Adsun script to your Mini App with one line of HTML.
The SDK is one JavaScript file. Add it once, in the <head> of your Mini App:
<script src="https://api.adsun.io/sdk.js"></script>After it loads you have window.Adsun and the <adsun-task> element. Nothing else to install.
Check that it works
Open your app and type in the browser console:
typeof window.Adsun // → "object"Using npm / a bundler?
Keep the script tag in index.html (Vite, Next.js and CRA all have one). Then use the hook from React, Vue & Unity.
TypeScript
The SDK ships full typings in sdk/types/adsun.d.ts. Copy that file into your project's types folder and window.Adsun, AdController and ShowPromiseResult are typed for you. If you only need a quick local declaration, this minimal one works:
type AdController = {
show(): Promise<{ done: boolean; description: string; state: "load" | "render" | "playing" | "destroy"; error: boolean }>;
};
declare global {
interface Window { Adsun?: { init(params: { blockId: string; debug?: boolean }): AdController } }
}TIP
The SDK also works without
telegram-web-app.js, but we recommend loading it — it gives better theme colors and safe areas.Still stuck? Write to support@adsun.io or our Telegram support — we answer fast.