Ads3Ads3
How Ad Network Works
Advertiser
Publisher
Quest
  • Telegram
  • Twitter
  • Discord
  • Press Kit
  • English
  • 简体中文
How Ad Network Works
Advertiser
Publisher
Quest
  • Telegram
  • Twitter
  • Discord
  • Press Kit
  • English
  • 简体中文
  • Exchange

  • Get Started

    • Introduction
    • Creating an Exchange Task
    • Traffic Export
    • Traffic Import
  • Code Integration

    • SDK Ad Integration
    • SDK Ad Integration (Advanced)
  • Reference

    • Glossary
    • SDK Installation

SDK Installation

To install the SDK using npm, run the following command:

npm install --save ton-ai-sdk

Initializing the SDK

In a React Project

To initialize the SDK in a React project, import it into your main file, such as App.jsx:

import { TonAdInit } from 'ton-ai-sdk'

Then, initialize the SDK within the useEffect hook:

useEffect(() => {
  // Set debug=true during testing to receive test ads
  const result = TonAdInit({ appId: 'your-app-id', debug: true })
  console.log('TonAdInit', result)
}, [])

Tips

Check out How to Get AppId for instructions on obtaining your AppId.

In Other Frameworks

For other frameworks, you can initialize the SDK after the page has fully loaded:

<script>
  document.addEventListener('DOMContentLoaded', function () {
    // Initialize TonAd after the DOM is ready
    // Set debug=true during testing to receive test ads
    TonAdInit({ appId: 'your-app-id', debug: true })
  })
</script>
Prev
Glossary