Nanfeng

Notes on software development, code, and curious ideas

Enabling Close Confirmation in a Telegram Mini App

Users can accidentally tap the close button in the upper-left corner of a Telegram Web App. The confirmation behavior is configured in the Mini App’s frontend, not in the bot.

Load the Telegram Web App SDK:

1
2
3
4
5
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script>
const tg = window.Telegram.WebApp;
tg.isClosingConfirmationEnabled = true;
</script>

Telegram will then display a confirmation sheet when the user tries to close the app.

Close confirmation

+