@telegram-apps/sdk
Made-from-scratch TypeScript library for seamless communication with Telegram Mini Apps functionality.
The code of this library is designed to simplify the process for developers interacting with Telegram Mini Apps. It consists of several individual components, each responsible for a specific aspect of the Telegram Mini Apps ecosystem.
Before you begin using the SDK, we highly recommend familiarizing yourself with the Telegram Mini Apps documentation to grasp the fundamental concepts of the platform.
Installation
bash
pnpm i @telegram-apps/sdk
bash
npm i @telegram-apps/sdk
bash
yarn add @telegram-apps/sdk
Prerequisites
Before diving deep into the documentation of this package, it is recommended to familiarize yourself with the following packages:
- @telegram-apps/signals - our own JavaScript signals used almost everywhere in the package.
- @telegram-apps/bridge - the lowest level communication layer with Telegram Mini Apps. The SDK uses it under the hood and re-exports some functionality.
Usage Example
ts
import { init, backButton } from '@telegram-apps/sdk';
// Init the package and actualize all global dependencies.
init();
// Mount the back button component and retrieve its actual
// state.
backButton.mount();
// When a user clicked the back button, go back in the
// navigation history.
const off = backButton.onClick(() => {
off();
window.history.back();
});