TMA Launch Tutorial
Create your App
- To connect your Mini App to the Telegram, place the SDK script
telegram-web-app.jsusing this code:
It's preferable to switch off cache in the HTML. To ensure your cache switched off, specify headers in your request according the following:
Cache-Control: no-store, must-revalidate
The modern way to connect SDK is npm package for Telegram Mini Apps SDK:
npm i @twa-dev/sdk
yarn add @twa-dev/sdk
pnpm add @twa-dev/sdk
You can find guide for
- When your Mini App is ready and deployed to the web server, follow to the next step.
Setting Up a Bot for the App
To connect your Mini App to the Telegram, you need to create a bot and set up a Mini App for it. Follow these steps to set up a new Telegram bot:
1. Start a Chat with BotFather
- Open the Telegram app or web version.
- Search for
@BotFatherin the search bar or follow the link https://t.me/BotFather.
- Start a chat with BotFather by clicking on the
2. Create a New Bot
/newbotcommand to BotFather.
- BotFather will ask you to choose a name for your bot. This is a display name and can contain spaces.
- Next, you'll be asked to choose a username for your bot. This must end in
sample_bot) and be unique.
3. Set Up Bot Mini App
/mybotscommand to BotFather.
- Choose your bot from the list and the Bot settings option
- Choose Menu button option
- Choose Edit menu button URL option and send URL to your Telegram Mini App, for example link from GitHub Pages deploy.
4. Accessing the Bot
- You can now search for your bot using its username in Telegram's search bar.
- Press the button next to attach picker to launch your Telegram Mini App in messenger
- You’re awesome!