@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.
Installation
bash
pnpm i @tma.js/bridge
bash
npm i @tma.js/bridge
bash
yarn add @tma.js/bridge
Usage
Here’s a basic example of how to use this package. For more details, refer to the next articles in the documentation.
ts
import { on, postEvent, applyPolyfills } from '@tma.js/bridge';
// Apply polyfills for Object.hasOwn. Bridge validators use it.
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();
});