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>