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

  • Get Started

    • Introduction
    • Get BlockId
    • Ad Integration Examples
  • Code Integration

    • Publisher Integration Checklist
    • SDK Integration for Native Ads
    • SDK Integration for Rewarded Ads
  • Reference

    • Code Examples
    • SDK Installation
    • Data Analysis and Revenue Settlement
    • Technical Manual

      • SDK API Reference
      • User Profile
      • API Ad Integration
    • Getting App Id
    • Glossary

SDK Installation

To install the SDK using npm, please 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 the SDK in 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 to learn how to obtain your AppId.

In Other Frameworks

For other frameworks, you can initialize the SDK once the page is fully loaded:

<script>
  document.addEventListener('DOMContentLoaded', function () {
    // Initialize TonAd after the DOM is ready
    // Set debug=true during testing to receive test ads
    const result = TonAdInit({ appId: 'your-app-id', debug: true })
  })
</script>
Prev
Code Examples
Next
Data Analysis and Revenue Settlement