Skip to content

@telegram-apps/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 @telegram-apps/sdk.

Installation

bash
pnpm i @telegram-apps/bridge
bash
npm i @telegram-apps/bridge
bash
yarn add @telegram-apps/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 {
  defineEventHandlers,
  on,
  postEvent,
} from '@telegram-apps/bridge';

// Define Mini Apps event handlers to receive 
// events from the Telegram native application.
defineEventHandlers();

// 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();
});

Released under the MIT License.