Skip to content

Commit 7d4bdcd

Browse files
committed
Add navigable table of contents to README
1 parent d1f336d commit 7d4bdcd

File tree

1 file changed

+66
-39
lines changed

1 file changed

+66
-39
lines changed

README.md

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Keep sections concise and examples compilable where possible.
44
-->
55

6+
<a id="readme-top"></a>
7+
68
# Telegram WebApp SDK
79

810
[![Crates.io](https://img.shields.io/crates/v/telegram-webapp-sdk)](https://crates.io/crates/telegram-webapp-sdk)
@@ -19,14 +21,49 @@
1921

2022
`telegram-webapp-sdk` provides a type-safe and ergonomic wrapper around the [Telegram Web Apps](https://core.telegram.org/bots/webapps) JavaScript API.
2123

24+
## Table of contents
25+
26+
- [Features](#features)
27+
- [Macros](#macros)
28+
- [Router](#router)
29+
- [Installation](#installation)
30+
- [Quick start](#quick-start)
31+
- [Yew](#yew)
32+
- [Leptos](#leptos)
33+
- [Mock environment](#mock-environment)
34+
- [User interactions](#user-interactions)
35+
- [Keyboard control](#keyboard-control)
36+
- [Closing confirmation](#closing-confirmation)
37+
- [Invoice payments](#invoice-payments)
38+
- [Sharing](#sharing)
39+
- [Settings button](#settings-button)
40+
- [Cloud storage](#cloud-storage)
41+
- [Home screen](#home-screen)
42+
- [Event callbacks](#event-callbacks)
43+
- [Background events](#background-events)
44+
- [Appearance](#appearance)
45+
- [Viewport](#viewport)
46+
- [Fullscreen and orientation](#fullscreen-and-orientation)
47+
- [Haptic feedback](#haptic-feedback)
48+
- [Device storage](#device-storage)
49+
- [Secure storage](#secure-storage)
50+
- [Biometric authentication](#biometric-authentication)
51+
- [Location manager](#location-manager)
52+
- [Device sensors](#device-sensors)
53+
- [Init data validation](#init-data-validation)
54+
- [API coverage](#api-coverage)
55+
- [Changelog](#changelog)
56+
- [License](#license)
57+
- [Metrics](#metrics)
58+
<p align="right"><a href="#readme-top">Back to top</a></p>
2259
## Features
2360

2461
- Comprehensive coverage of Telegram Web App JavaScript APIs.
2562
- Framework integrations for **Yew** and **Leptos**.
2663
- Optional macros for automatic initialization and routing.
2764
- Biometric authentication helpers, viewport metrics, and theme utilities in
2865
step with the Telegram WebApp API 9.2 feature set.
29-
66+
<p align="right"><a href="#readme-top">Back to top</a></p>
3067
## Macros
3168

3269
The macros are available with the `macros` feature. Enable it in your `Cargo.toml`:
@@ -52,7 +89,7 @@ When running outside Telegram in debug builds, `telegram_app!` loads mock
5289
settings from `telegram-webapp.toml`.
5390
- Configurable mock `Telegram.WebApp` for local development and testing.
5491
- API helpers for user interactions, storage, device sensors and more.
55-
92+
<p align="right"><a href="#readme-top">Back to top</a></p>
5693
## Router
5794

5895
The `macros` feature ships with a minimal in-memory [`Router`](src/router.rs)
@@ -79,21 +116,7 @@ impl CustomRouter {
79116
80117
telegram_router!(CustomRouter);
81118
```
82-
83-
## Table of contents
84-
85-
- [Installation](#installation)
86-
- [Quick start](#quick-start)
87-
- [Mock environment](#mock-environment)
88-
- [User interactions](#user-interactions)
89-
- [Keyboard control](#keyboard-control)
90-
- [Appearance](#appearance)
91-
- [Viewport](#viewport)
92-
- [Biometric authentication](#biometric-authentication)
93-
- [API coverage](#api-coverage)
94-
- [Changelog](#changelog)
95-
- [License](#license)
96-
119+
<p align="right"><a href="#readme-top">Back to top</a></p>
97120
## Installation
98121

99122
Add the crate to your `Cargo.toml`:
@@ -113,7 +136,7 @@ telegram-webapp-sdk = { version = "0.2.12", features = ["macros", "yew", "mock"]
113136
- `yew` &mdash; exposes a `use_telegram_context` hook and a `BottomButton` component.
114137
- `leptos` &mdash; integrates the context into the Leptos reactive system.
115138
- `mock` &mdash; installs a configurable mock `Telegram.WebApp` for local development.
116-
139+
<p align="right"><a href="#readme-top">Back to top</a></p>
117140
## Quick start
118141

119142
### Yew
@@ -179,7 +202,7 @@ fn App() -> impl IntoView {
179202
view! { <BottomButton button=Btn::Main text /> }
180203
}
181204
```
182-
205+
<p align="right"><a href="#readme-top">Back to top</a></p>
183206
## Mock environment
184207

185208
The `mock` feature simulates a `Telegram.WebApp` instance, enabling local development without Telegram:
@@ -188,7 +211,7 @@ The `mock` feature simulates a `Telegram.WebApp` instance, enabling local develo
188211
let config = telegram_webapp_sdk::mock::MockConfig::default();
189212
let ctx = telegram_webapp_sdk::mock::install(config)?;
190213
```
191-
214+
<p align="right"><a href="#readme-top">Back to top</a></p>
192215
## User interactions
193216

194217
Request access to sensitive user data or open the contact interface:
@@ -211,7 +234,7 @@ app.request_write_access(|granted| {
211234
```
212235

213236
These calls require the user's explicit permission before any information is shared.
214-
237+
<p align="right"><a href="#readme-top">Back to top</a></p>
215238
## Keyboard control
216239

217240
Hide the native keyboard when it's no longer required:
@@ -224,7 +247,7 @@ app.hide_keyboard()?;
224247
# Ok(())
225248
# }
226249
```
227-
250+
<p align="right"><a href="#readme-top">Back to top</a></p>
228251
## Closing confirmation
229252

230253
Prompt users before the Mini App closes:
@@ -240,6 +263,7 @@ app.disable_closing_confirmation()?;
240263
# Ok(())
241264
# }
242265
```
266+
<p align="right"><a href="#readme-top">Back to top</a></p>
243267
## Invoice payments
244268

245269
Open invoices and react to the final payment status:
@@ -257,6 +281,7 @@ app.off_event(handle)?;
257281
# Ok(())
258282
# }
259283
```
284+
<p align="right"><a href="#readme-top">Back to top</a></p>
260285
## Sharing
261286

262287
Share links, prepared messages, or stories and join voice chats:
@@ -277,7 +302,7 @@ app.share_to_story("https://example.com/image.png", Some(&params.into()))?;
277302
# Ok(())
278303
# }
279304
```
280-
305+
<p align="right"><a href="#readme-top">Back to top</a></p>
281306
## Settings button
282307

283308
Control the Telegram client's settings button and handle user clicks:
@@ -295,7 +320,7 @@ off_click(&cb)?;
295320
# Ok(())
296321
# }
297322
```
298-
323+
<p align="right"><a href="#readme-top">Back to top</a></p>
299324
## Cloud storage
300325

301326
Persist small key-value pairs in Telegram's cloud using `CloudStorage`:
@@ -315,7 +340,7 @@ assert_eq!(value, Some("1".into()));
315340
```
316341

317342
All functions return a `Promise` and require the Web App to run inside Telegram.
318-
343+
<p align="right"><a href="#readme-top">Back to top</a></p>
319344
## Home screen
320345

321346
Prompt users to add the app to their home screen and check the current status:
@@ -331,7 +356,7 @@ app.check_home_screen_status(|status| {
331356
# Ok(())
332357
# }
333358
```
334-
359+
<p align="right"><a href="#readme-top">Back to top</a></p>
335360
## Event callbacks
336361

337362
Callback registration methods return an `EventHandle` for later deregistration.
@@ -378,7 +403,7 @@ Supported background events:
378403
| `popupClosed` | object `{ button_id: Option<String> }` |
379404
| `qrTextReceived` | scanned text `String` |
380405
| `clipboardTextReceived` | clipboard text `String` |
381-
406+
<p align="right"><a href="#readme-top">Back to top</a></p>
382407
## Appearance
383408

384409
Customize colors and react to theme or safe area updates:
@@ -408,7 +433,7 @@ app.off_event(content_handle)?;
408433
# Ok(())
409434
# }
410435
```
411-
436+
<p align="right"><a href="#readme-top">Back to top</a></p>
412437
## Viewport
413438

414439
Inspect the Mini App viewport size and subscribe to updates:
@@ -430,7 +455,7 @@ callback.forget();
430455
# Ok(())
431456
# }
432457
```
433-
458+
<p align="right"><a href="#readme-top">Back to top</a></p>
434459
## Fullscreen and orientation
435460

436461
Control the Mini App display and screen orientation:
@@ -448,7 +473,7 @@ app.exit_fullscreen()?;
448473
# Ok(())
449474
# }
450475
```
451-
476+
<p align="right"><a href="#readme-top">Back to top</a></p>
452477
## Haptic feedback
453478

454479
Trigger device vibrations through Telegram's [HapticFeedback](https://core.telegram.org/bots/webapps#hapticfeedback) API:
@@ -464,7 +489,7 @@ notification_occurred(HapticNotificationType::Success)?;
464489
selection_changed()?;
465490
# Ok::<(), wasm_bindgen::JsValue>(())
466491
```
467-
492+
<p align="right"><a href="#readme-top">Back to top</a></p>
468493
## Device storage
469494

470495
Persist lightweight data on the user's device:
@@ -478,7 +503,7 @@ let value = get("theme").await?;
478503
# Ok(())
479504
# }
480505
```
481-
506+
<p align="right"><a href="#readme-top">Back to top</a></p>
482507
## Secure storage
483508

484509
Store sensitive data encrypted and restorable:
@@ -492,7 +517,7 @@ let _ = restore("token").await?;
492517
# Ok(())
493518
# }
494519
```
495-
520+
<p align="right"><a href="#readme-top">Back to top</a></p>
496521
## Biometric authentication
497522

498523
Guard privileged actions behind the BiometricManager API:
@@ -511,7 +536,7 @@ if is_biometric_available()? {
511536
# Ok(())
512537
# }
513538
```
514-
539+
<p align="right"><a href="#readme-top">Back to top</a></p>
515540
## Location manager
516541

517542
Retrieve user location and react to related events via Telegram's location manager:
@@ -531,7 +556,7 @@ on_location_requested(&cb)?;
531556
cb.forget();
532557
# Ok::<(), wasm_bindgen::JsValue>(())
533558
```
534-
559+
<p align="right"><a href="#readme-top">Back to top</a></p>
535560
## Device sensors
536561

537562
Access motion sensors if the user's device exposes them.
@@ -548,6 +573,7 @@ stop()?;
548573
Callbacks for sensor lifecycle events are available through `on_started`,
549574
`on_changed`, `on_stopped`, and `on_failed` functions for accelerometer,
550575
gyroscope, and device orientation sensors.
576+
<p align="right"><a href="#readme-top">Back to top</a></p>
551577
## Init data validation
552578

553579
Validate the integrity of the `Telegram.WebApp.initData` payload on the server.
@@ -577,19 +603,19 @@ TelegramWebApp::validate_init_data(
577603
578604
# Ok::<(), Box<dyn std::error::Error>>(())
579605
```
580-
606+
<p align="right"><a href="#readme-top">Back to top</a></p>
581607
## API coverage
582608

583609
<!-- webapp_api_summary:start -->
584610
**WebApp API coverage:** version `9.2` matches the latest Telegram WebApp API release `9.2`. Synced in commit [92abbf7](https://github.com/RAprogramm/telegram-webapp-sdk/commit/92abbf7) (recorded on 2025-09-21).
585611
<!-- webapp_api_summary:end -->
586612

587613
See [WEBAPP_API.md](./WEBAPP_API.md) for a checklist of supported Telegram WebApp JavaScript API methods and features.
588-
614+
<p align="right"><a href="#readme-top">Back to top</a></p>
589615
## Changelog
590616

591617
See [CHANGELOG.md](./CHANGELOG.md) for release notes.
592-
618+
<p align="right"><a href="#readme-top">Back to top</a></p>
593619
## License
594620

595621
`telegram-webapp-sdk` is licensed under either of
@@ -598,7 +624,8 @@ See [CHANGELOG.md](./CHANGELOG.md) for release notes.
598624
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
599625

600626
at your option.
601-
627+
<p align="right"><a href="#readme-top">Back to top</a></p>
602628
## Metrics
603629

604630
![Metrics](https://github.com/RAprogramm/infra-metrics-insight-renderer/blob/main/metrics/telegram-webapp-sdk.svg)
631+
<p align="right"><a href="#readme-top">Back to top</a></p>

0 commit comments

Comments
 (0)