Installation
The tma CLI is the primary tool for creating, developing, and deploying Telegram Mini Apps on TMA.sh.
Install the CLI
Section titled “Install the CLI”Install the CLI globally with Bun:
bun add -g @tma.sh/cliVerify the installation:
tma --versionLog in to your account
Section titled “Log in to your account”-
Run the login command:
Terminal window tma loginThis opens your browser and starts an OAuth device code flow. Authorize the CLI to connect it to your TMA.sh account.
-
Once authorized, credentials are stored locally. You only need to do this once per machine.
Create a new project
Section titled “Create a new project”Use tma init to scaffold a new project from a template:
tma init my-appThe interactive prompt walks you through:
- Template selection — pick a framework (Vite React, Vite Vue, Vite Svelte, or Plain HTML).
- API routes — optionally scaffold a
server/api/index.tsfile for edge API routes (Hono scaffolded by default, but any fetch-compatible framework works). - Bot handlers — optionally set up bot command and message handlers.
- Dependency installation — automatically runs
bun install(ornpm installwhen Bun is unavailable).
After init finishes, your project is ready to develop:
cd my-apptma devtma init only scaffolds local files. To use authenticated project commands like tma deploy, tma env, tma logs, or tma bot, run tma link next to write the full project ID/org ID config.
Link an existing project
Section titled “Link an existing project”If you already have a frontend project and want to deploy it to TMA.sh, run tma link from the project root:
cd my-existing-apptma linkThis prompts you to select an org and project, then writes the .tma/project.json config file to connect your local directory to your TMA.sh account.
If you select + Create new project in the prompt, tma link creates the project first, then writes the same full config.
Project configuration
Section titled “Project configuration”After tma init or tma link, a .tma/project.json file is created in your project root.
tma init creates a partial config with only the project name:
{ "projectName": "my-app"}tma link creates the full config with all fields:
{ "projectId": "11111111-2222-4333-8444-555555555555", "orgId": "66666666-7777-4888-8999-000000000000", "projectName": "my-app"}This file identifies the project when running CLI commands. Commit .tma/project.json, but ignore local dev artifacts under .tma/:
.tma/*!.tma/project.jsonSet up your Telegram bot
Section titled “Set up your Telegram bot”Every TMA.sh project is connected to a Telegram bot. If you do not have one yet, create it now.
-
Open Telegram and start a conversation with @BotFather.
-
Send
/newbotand follow the prompts to choose a name and username. -
Copy the bot token that BotFather gives you. You will need it when connecting your project.
-
Run
tma bot registerand paste the token when prompted:Terminal window tma bot registerTMA.sh configures the bot’s Web App URL automatically on each deployment.
Next steps
Section titled “Next steps”Your CLI is installed, your account is connected, and your project is ready. Head to Your First Deploy to ship your first Telegram Mini App.