A lightweight wrapper to load and initialize the Telegram Web App JavaScript SDK dynamically.
- Loads Telegram Web App script asynchronously
- Resolves with the
Telegramobject after the SDK is ready - Automatically skips loading if already present
npm install @atomazing-org/telegram-web-appimport { Telegram } from '@atomazing-org/telegram-web-app';
Telegram?.WebApp?.ready();
console.log(Telegram?.WebApp?.platform);The module exports a single object Telegram, which is awaited internally and is ready to use upon import.
- Loads
https://telegram.org/js/telegram-web-app.jsdynamically - Returns the
window.Telegramglobal object after the script loads successfully - Throws an error if the script fails to load
import { Telegram } from '@atomazing-org/telegram-web-app';
Telegram.WebApp.expand();
Telegram.WebApp.setBackgroundColor("#ffffff");npm install
npm run buildMIT