Skip to content
RAprogramm edited this page Nov 4, 2025 · 3 revisions

Welcome to telegram-webapp-sdk

Crates.io docs.rs CI codecov

A type-safe, ergonomic Rust wrapper for the Telegram Web Apps JavaScript API.

What is telegram-webapp-sdk?

telegram-webapp-sdk provides Rust developers with a comprehensive toolkit for building Telegram Mini Apps (WebApps). It offers:

  • Type Safety: Rust bindings that catch errors at compile time
  • Framework Integration: First-class support for Yew and Leptos
  • Complete API Coverage: Wraps the entire Telegram WebApp JavaScript API
  • Developer Experience: Macros for routing, initialization, and component creation

Quick Links

Key Features

🎯 Comprehensive API Coverage

  • User interactions (contact sharing, phone requests)
  • Invoice payments
  • Cloud & device storage
  • Biometric authentication
  • Location services
  • Device sensors (accelerometer, gyroscope)
  • Haptic feedback
  • QR code scanning
  • And more...

🚀 Framework Support

Works seamlessly with popular Rust web frameworks:

  • Yew - Component-based UI with hooks
  • Leptos - Fine-grained reactivity

🧩 Powerful Macros

use telegram_webapp_sdk::{telegram_app, telegram_router};

#[telegram_app(auto_init)]
fn App() -> Html {
    telegram_router! {
        "/" => Home,
        "/profile" => Profile,
    }
}

🧪 Testing Support

Built-in mock environment for testing without Telegram:

use telegram_webapp_sdk::mock::init_mock;

init_mock(MockConfig::default());

Project Status

  • Current Version: 0.3.0
  • MSRV: Rust 1.90+
  • Telegram WebApp API: 9.2
  • License: MIT

Community

Breaking Changes in v0.3.0

Version 0.3.0 removes server-side validation from the SDK. This was a security improvement - bot tokens should never be in client code.

For server-side validation, use init-data-rs:

use init_data_rs::{validate, InitData};

async fn authenticate(init_data_str: &str, bot_token: &str)
    -> Result<InitData, Box<dyn std::error::Error>> {
    let init_data: InitData = validate(init_data_str, bot_token, Some(3600))?;
    Ok(init_data)
}

See the migration guide for details.

Clone this wiki locally