Skip to content

Telegram Mini Apps (Web app)

Guide is WIP.

For start, we recommend Telegram apps (tma.js).

Telegram documentation | Figma UI Kit | Telegram Developers Community

Scaffold monorepo

With create-gramio you can easily start developing Telegram mini app in monorepo. You can start a project with tma.js, Elysiajs and GramIO in a minute!

bash
npm create gramio@latest ./bot
bash
yarn create gramio@latest ./bot
bash
pnpm create gramio@latest ./bot
bash
bun create gramio@latest ./bot

and choose the type of project you need!

For example, this is what a monorepo created using create-gramio looks like

tree
├── apps
│   ├── bot
│   ├── mini-app
│   └── server
└── packages
    └── db

Scaffold via Telegram apps (tma.js)

bash
npm create @telegram-apps/mini-app@latest ./bot
bash
yarn create @telegram-apps/mini-app@latest ./bot
bash
pnpm create @telegram-apps/mini-app@latest ./bot
bash
bun create @telegram-apps/mini-app@latest ./bot

This command will help you scaffold a project with a template that matches you from the list:

HTTPS on localhost

BotFather only accepts http:// links and getting into the test environment can be problematic, so let's figure out how to work with https:// and localhost.

  1. First you need to install mkcert:
bash
choco install mkcert
# or with Scoop
scoop bucket add extras
scoop install mkcert
bash
brew install mkcert
brew install nss # if you use Firefox
bash
sudo apt install libnss3-tools
brew install mkcert
  1. Then you need to create a local certificate for the custom hostname and instal it:
bash
mkcert mini-app.local
mkcert --install
  1. Add the custom hostname to your hosts file:
powershell
echo "127.0.0.1 mini-app.local" >> C:\Windows\System32\drivers\etc\hosts
bash
sudo echo "127.0.0.1 mini-app.local" >> /etc/hosts
  1. Configure it in vite.config.ts
ts

import fs from "node:fs";
import { defineConfig } from "vite";

export default defineConfig({
    server: {
        port: 443,
        host: "0.0.0.0",
        hmr: {
            host: "mini-app.local",
            port: 443,
        },
        https: {
            key: fs.readFileSync("./mini-app.local-key.pem"),
            cert: fs.readFileSync("./mini-app.local.pem"),
        },
    },
});

🔥 Now you don't need any tunnels and you are happy to develop with HMR in the telegram production environment!