telegram-sdk
v0.0.7
Published
Telegram Web App - (Uses July 7, 2024, Bot API 7.7)
Downloads
44
Maintainers
Readme
Installation
pnpm add telegram-sdk
you don't need to install the Telegram JS module separately, as it is included in this package.
Setup
- Import core module in root file of your project.
import 'telegram-sdk/core';
Usage
- Use the API provided by the Telegram JS module.
import { WebApp, WebView } from 'telegram-sdk';
// to display the initData
console.log(WebApp.initData);
// to show the main button
WebApp.MainButton.show();
// to set the app background color
WebApp.setBackgroundColor('#f60000')
// to set the app header color
WebApp.setHeaderColor('bg_color');
// Display a swipe vertical by event
WebView.postEvent('web_app_setup_swipe_behavior', false, {
allow_vertical_swipe: false,
});
// ready method must come last
WebApp.ready();
disableVerticalSwipes
import { WebApp, WebView } from 'telegram-sdk';
// Config something...
WebApp.expand(); // Expand app
WebApp.disableClosingConfirmation();
WebApp.disableVerticalSwipes(); // Disable Vertical Swiper
// ready method must come last
WebApp.ready();
Documentation
Refer to the official Telegram documentation for Web Apps to explore additional features available through WebApp.
Core script is available in the Telegram JS module