TADS Docs
  • About Us
  • Getting Started
    • For Advertiser
      • Launch Ad
      • Ad Analysis
      • Ad Statuses
      • Ad Targeting
        • Country
        • Locales
        • Platforms
        • User Spending Power
        • Telegram Premium
        • Traffic Type
        • Audience
    • For Publisher
      • Register Account
      • Create Widget
      • Embed Widget
        • React
        • Vanilla JS
      • Widget Analysis
  • RESOURSES
    • Ad Formats
    • Ad Requirements
    • Moderation
    • Payment
    • Glossary
Powered by GitBook
On this page
  • 1. Insert widget code in the app
  • 2. Add your widget ID
  • 3. Set a reward (if needed)
  1. Getting Started
  2. For Publisher
  3. Embed Widget

React

PreviousEmbed WidgetNextVanilla JS

Last updated 3 months ago

1. Insert widget code in the app

Install the package and initialize the widget using the following code example for the selected format:

import React from "react";
import { TadsWidget } from 'react-tads-widget';

const PageWithAds: React.FC = () => {
    const rewardUserByClick = () => {
        console.log("User rewarded for click");
    };
    
    const onAdsNotFound = () => {
        console.log("Not found ads for this user");
    }

    return (
        <div className="container">
            <TadsWidget id="unique-widget-id" debug={false} onClickReward={rewardUserByClick} onAdsNotFound={onAdsNotFound} />
        </div>
    );
}

export default PageWithAds;

2. Add your widget ID

Replace YOUR_WIDGET_ID with the corresponding widget ID you received from your personal account.

3. Set a reward (if needed)

If you want to incentivize users to view or click on the ads, add code to the onShowRewardCallback and onClickRewardCallback and onAdsNotFound functions to reward the user for viewing and/or clicking, respectively. You can see all configuration parameters in our

react-tads-widget
npm-package