CLI Commands
Detailed reference for every command available in the tma CLI.
tma login
Section titled “tma login”Authenticate with TMA.sh using the device code flow.
tma loginThe CLI opens your browser and displays a one-time code. Enter the code in the browser to authorize the session. Once confirmed, credentials are stored locally and used for all subsequent commands.
Credentials are saved to ~/.tma/credentials.json. They persist across sessions until you run tma logout or they expire.
tma logout
Section titled “tma logout”Clear stored authentication credentials.
tma logoutRemoves the local credentials file. You will need to run tma login again before using any authenticated commands.
tma init [project-name]
Section titled “tma init [project-name]”Create a new TMA.sh project with interactive scaffolding.
tma init my-appIf project-name is omitted, the CLI prompts you for one.
The scaffolding wizard walks through the following:
- Template selection — choose from Vite (React, Vue, or Svelte) or Plain HTML.
- API routes — optionally include a
server/api/index.tsfile for edge API routes powered by Hono. - Bot handlers — optionally include a
bot/index.tsfile for Telegram bot command handlers. - Dependency installation — runs
bun installautomatically after scaffolding.
The command creates the project directory, writes all template files, and generates .tma/project.json to link the directory to your TMA.sh project.
my-app/ .tma/ project.json src/ ... server/ # only if API routes selected api/ index.ts bot/ # only if bot handlers selected index.ts index.html package.jsontma link
Section titled “tma link”Link the current directory to an existing TMA.sh project.
tma linkUse this when you have an existing codebase that you want to deploy to TMA.sh, or when cloning a repo that does not yet have a .tma/project.json file.
The CLI fetches your projects and prompts you to select one. After selection, it writes .tma/project.json to the current directory.
tma dev
Section titled “tma dev”Start the local development environment.
tma devThis command starts everything you need for local development:
- Vite dev server on port
5173with hot module replacement. - API routes (if
server/api/index.tsexists): starts an esbuild watcher and Miniflare on port8787. - Bot handlers (if
bot/index.tsexists): starts Miniflare on port8788for bot webhook processing.
Vite proxies /api/* and /bot/* requests to the respective Miniflare instances so your frontend, API, and bot handlers share the same origin during development.
tma deploy
Section titled “tma deploy”Trigger a manual deployment to production.
tma deployTriggers a server-side deployment by calling the TMA.sh API, then polls for completion. The CLI does not build locally or upload assets — all building happens on the server.
This command is for manual deployments. If you have auto-deploy enabled (the default), pushing to your main branch on GitHub triggers a deployment automatically without needing to run this command.
The CLI streams build status to your terminal and prints the live URL when the deployment is complete:
Deployment triggered...Building (Vite detected)...Deployment live at https://my-app.tma.shOptions
Section titled “Options”| Flag | Description |
|---|---|
--preview | Trigger a preview deployment instead of production |
tma env
Section titled “tma env”Manage environment variables and secrets for your project.
# List all environment variablestma env list
# Set a variable (use = between key and value)tma env set API_KEY=sk-abc123
# Remove a variabletma env remove API_KEY
# Pull env vars to a local .env.local file (values are redacted)tma env pullAll environment variables are set for the production environment. Environment scoping for preview and development is managed through the dashboard.
tma env pull
Section titled “tma env pull”Writes a .env.local file to the current directory containing the secret key names from your project. Values are redacted by the API — this is useful for seeing which variables are configured without exposing actual secrets.
Security
Section titled “Security”All environment variables are encrypted at rest. They are injected at build time and available as process.env.* in API routes. Sensitive values (tokens, keys) are masked in build logs.
tma logs
Section titled “tma logs”View build logs for recent deployments.
# View logs for the latest deploymenttma logs
# View logs for a specific deploymenttma logs --deployment dpl_abc123
# Stream logs in real timetma logs --followOptions
Section titled “Options”| Flag | Description |
|---|---|
--deployment <id> | View logs for a specific deployment |
--follow | Stream logs in real time |
Displays the build output, including framework detection, build commands, asset upload progress, and any errors. Useful for debugging failed deployments.
tma bot
Section titled “tma bot”Manage Telegram bots registered with your TMA.sh project.
# List all registered bots (default when no subcommand is given)tma bottma bot list
# Register a new bottma bot register
# Remove a registered bottma bot remove
# Check bot statustma bot statusSubcommands
Section titled “Subcommands”| Subcommand | Description |
|---|---|
list | List all registered bots for the project (default) |
register | Register a Telegram bot with TMA.sh. Prompts for the bot token and environment selection (production or staging). |
remove | Remove a registered bot from the project |
status | Check the status of registered bots |
Running tma bot with no subcommand is equivalent to tma bot list.