Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Add the dependency

Add the crate to your Cargo.toml:

[dependencies]
telegram-webapp-sdk = "0.11"

Enable feature flags

The crate ships with no default features (default = []), so you opt into exactly what you need:

telegram-webapp-sdk = { version = "0.11", features = ["macros", "yew", "leptos", "mock"] }
FeaturePurpose
macrostelegram_app!, telegram_page!, and telegram_router! macros
yewYew context hook, reactive hooks, and system-button components
leptosLeptos context provider, reactive hooks, and system-button components
mockConfigurable mock Telegram.WebApp for local development
fullShortcut for macros + yew + leptos + mock

Typically you enable a single framework feature plus mock:

# Leptos app with local mock support
telegram-webapp-sdk = { version = "0.11", features = ["leptos", "mock"] }

Minimum Supported Rust Version

The MSRV is Rust 1.96 (edition 2024). Older toolchains are not supported.

rustup update stable
rustc --version   # must be >= 1.96

Target the browser

Telegram Mini Apps run as WebAssembly in the Telegram in-app browser, so you build for the wasm32-unknown-unknown target:

rustup target add wasm32-unknown-unknown

Bundling with Trunk or wasm-pack

Use a WASM bundler to produce the final .wasm + JS glue and an index.html.

Trunk (recommended for whole apps — this is what the demo uses):

cargo install trunk
trunk serve   # dev server with live reload
trunk build --release

A minimal index.html for Trunk pulls in Telegram’s script and your crate:

<!doctype html>
<html>
  <head>
    <script src="https://telegram.org/js/telegram-web-app.js"></script>
    <link data-trunk rel="rust" />
  </head>
  <body></body>
</html>

wasm-pack (for libraries or JS-driven integration):

cargo install wasm-pack
wasm-pack build --target web

Next steps