Skip to content

Mini App Overview

Mini Apps are lightweight web applications that run inside the chat interface, deeply integrated with the client through a JavaScript API to deliver native-level interactive experiences.

Features

  • Seamless Integration — Opens directly within the chat window without redirecting to an external browser
  • Native Interaction — Access native UI components such as back button, main button, and haptic feedback
  • Theme Adaptation — Automatically adapts to the user's light/dark theme
  • Secure Validation — Built-in data signing mechanism to ensure data integrity
  • Cloud Storage — Key-value cloud storage, device storage, and encrypted secure storage
  • Sensor Access — Read accelerometer, gyroscope, and device orientation data
  • Biometric Auth — Support for fingerprint and face recognition authentication

Initialization

Mini Apps are initialized by including the JavaScript SDK in your HTML:

html
<script src="https://oauth.safew.org/js/safew-web-app.js"></script>

Once included, the global object window.Telegram.WebApp becomes available. It is recommended to call Telegram.WebApp.ready() after the page has loaded to notify the client that the Mini App is ready.

javascript
const tg = window.Telegram.WebApp;

tg.ready();

// Access init data
console.log(tg.initData);
console.log(tg.initDataUnsafe);

Module Index

ModuleDescription
WebApp Properties30+ read-only properties of the WebApp object including platform, version, viewport size, etc.
WebApp Methods30+ methods of the WebApp object including UI control, data sending, link opening, etc.
UI ComponentsBackButton, BottomButton, SettingsButton, HapticFeedback
ThemeThemeParams with 15 color parameters, CSS variables, safe area insets
Events40+ events covering lifecycle, viewport changes, button interactions, etc.
PopupsPopups, alerts, confirmations, QR scanning, clipboard, invoices, sharing, etc.
Cloud StorageCloudStorage API with up to 1024 key-value pairs
Device StorageDeviceStorage API with 5MB local persistent storage
Secure StorageSecureStorage API with up to 10 encrypted items
SensorsAccelerometer, DeviceOrientation, Gyroscope
Location & BiometricLocationManager and BiometricManager
Init DataWebAppInitData, WebAppUser, WebAppChat data types
Data ValidationHMAC-SHA256 server-side validation + Ed25519 third-party validation