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
| Module | Description |
|---|---|
| WebApp Properties | 30+ read-only properties of the WebApp object including platform, version, viewport size, etc. |
| WebApp Methods | 30+ methods of the WebApp object including UI control, data sending, link opening, etc. |
| UI Components | BackButton, BottomButton, SettingsButton, HapticFeedback |
| Theme | ThemeParams with 15 color parameters, CSS variables, safe area insets |
| Events | 40+ events covering lifecycle, viewport changes, button interactions, etc. |
| Popups | Popups, alerts, confirmations, QR scanning, clipboard, invoices, sharing, etc. |
| Cloud Storage | CloudStorage API with up to 1024 key-value pairs |
| Device Storage | DeviceStorage API with 5MB local persistent storage |
| Secure Storage | SecureStorage API with up to 10 encrypted items |
| Sensors | Accelerometer, DeviceOrientation, Gyroscope |
| Location & Biometric | LocationManager and BiometricManager |
| Init Data | WebAppInitData, WebAppUser, WebAppChat data types |
| Data Validation | HMAC-SHA256 server-side validation + Ed25519 third-party validation |
