- Dynamically inject the Claimr widget tailored for Telegram.
- Understand the interaction between the Claimr widget and the Telegram Mini App API.
- Configure the required Claimr campaign settings for Telegram integration.
src/claimr_wrapper.tsx: Handles Claimr widget injection and configuration.src/example_app.tsx: Main UI component demonstrating Telegram API initialization.
- Node.js (v18+ recommended) — Install Node.js
- npm or yarn — comes with Node.js (or install Yarn separately)
Running the project
1
Navigate to the project folder
2
Install dependencies
Using npm:Using Yarn:
3
Start the development server
Using npm:Using Yarn:
4
View in browser
The app will be available at
http://localhost:3000.Optional: build for production
To create a production-ready build:build/ folder.
Claimr widget integration (claimr_wrapper.tsx)
TheClaimrWrapper component is responsible for dynamically injecting the Claimr widget script into your application page.
Script source
The widget script is loaded from https://widgets.claimr.io/claimr.min.js.
Script attributes
It’s injected with the following custom attributes:
Telegram Mini App behavior (example_app.tsx)
This component demonstrates initializing the Telegram Mini App API to ensure the webview behaves correctly within Telegram:expand(): Maximizes the Mini App window.enableClosingConfirmation(): Prompts the user before they close the Mini App.disableVerticalSwipes(): Prevents vertical swipes from accidentally closing or navigating away from the Mini App.
How it works (user view)
- A Telegram user opens your Mini App containing the Claimr integration.
- The
ClaimrWrapperinjects the widget script with thedata-platform='telegram'attribute. - The Claimr widget initializes and reads the
window.Telegram.WebAppcontext to automatically identify the Telegram user (using their Telegram ID and other available data). - The widget displays relevant tasks or quests based on the campaign configuration and the identified user.
- If necessary for specific tasks, the widget might prompt the user to link other accounts (like Discord, email, or a wallet) through separate flows within the widget.
- Task completions and results are synced back to Claimr’s backend, associated with the user’s Telegram identity.
Campaign configuration: required settings
To ensure the Claimr widget functions correctly within your Telegram Mini App and automatically recognizes users, specific campaign settings are required.
- Navigate to Sign-in options: Open your Claimr dashboard, go to your specific campaign, click Settings, then select Sign-in options.
- Set the following parameter: Select sign-in services — Ensure that Telegram is selected in this field. This explicitly allows users to authenticate and interact with your campaign using their Telegram identity provided by the Mini App environment.