-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
RAprogramm edited this page Nov 4, 2025
·
3 revisions
A type-safe, ergonomic Rust wrapper for the Telegram Web Apps JavaScript API.
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
- 1. Introduction - What is the SDK and how it works
- 2. Installation & Setup - Get started with professional project setup
- 3. Core Concepts - Understand initialization, context, and types
- 10. Demo & Examples Deep Dive - Complete guide to demo and examples with detailed local installation
- 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...
Works seamlessly with popular Rust web frameworks:
- Yew - Component-based UI with hooks
- Leptos - Fine-grained reactivity
use telegram_webapp_sdk::{telegram_app, telegram_router};
#[telegram_app(auto_init)]
fn App() -> Html {
telegram_router! {
"/" => Home,
"/profile" => Profile,
}
}Built-in mock environment for testing without Telegram:
use telegram_webapp_sdk::mock::init_mock;
init_mock(MockConfig::default());- Current Version: 0.3.0
- MSRV: Rust 1.90+
- Telegram WebApp API: 9.2
- License: MIT
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.