@tma.js/bridge
v2.2.0
Published
TypeScript package to provide communication layer between Mini App and Telegram application.
Maintainers
Readme
@tma.js/bridge
The lowest level communication layer with Telegram Mini Apps.
This package provides fundamental utilities and types for developing applications on the Telegram Mini Apps platform.
While a developer can use this package alone, it's recommended to use a higher-level package like @tma.js/sdk.
Installation
pnpm i @tma.js/bridge
# or
npm i @tma.js/bridge
# or
yarn add @tma.js/bridgeUsage
Here’s a basic example of how to use this package. For more details, refer to the package complete documentation.
import { on, postEvent, applyPolyfills } from '@tma.js/bridge';
// The package uses some polyfills, so let's use them.
applyPolyfills();
// Show the back button, wait for it to be clicked once,
// then hide it.
postEvent('web_app_setup_back_button', { is_visible: true });
const off = on('back_button_pressed', () => {
postEvent('web_app_setup_back_button', { is_visible: false });
off();
});