Skip to content

Your First Deploy

This walkthrough takes you from an empty directory to a live Telegram Mini App. You will scaffold a project, test it locally, and deploy it to production.

  1. Scaffold the project. Run tma init and select the Vite React template:

    Terminal window
    tma init my-first-app
  2. Enter the project directory.

    Terminal window
    cd my-first-app
  3. Link the directory to a TMA.sh project.

    Terminal window
    tma link

    If needed, choose + Create new project in the prompt.

  4. Edit your app. Open src/App.tsx and replace the contents with a simple Mini App that greets the user:

    import { useEffect, useState } from "react";
    function App() {
    const [name, setName] = useState("there");
    useEffect(() => {
    const webapp = window.Telegram?.WebApp;
    if (webapp) {
    webapp.ready();
    const user = webapp.initDataUnsafe?.user;
    if (user?.first_name) {
    setName(user.first_name);
    }
    }
    }, []);
    return (
    <main style={{ padding: "2rem", textAlign: "center" }}>
    <h1>Hello, {name}!</h1>
    <p>Your first Telegram Mini App is running.</p>
    </main>
    );
    }
    export default App;
  5. Start the dev server. The tma dev command starts a local Vite dev server with hot reload:

    Terminal window
    tma dev

    You will see output like:

    Local: http://localhost:5173
  6. Test locally in the browser. Open http://localhost:5173 and verify hot module replacement works while you edit.

Once you are happy with the app, deploy it to the world.

  1. Initialize a Git repo and push to GitHub.

    Terminal window
    git init
    git add .
    git commit -m "init"
    git remote add origin https://github.com/your-username/my-first-app.git
    git push -u origin main
  2. Connect the repository. Open the TMA.sh dashboard, navigate to your project, and connect your GitHub repository. This installs a GitHub webhook that triggers deployments on pushes to your configured deploy branch (default: main).

  3. Push a change to trigger a deploy. Any push to main kicks off an automatic deployment. Check status in the dashboard or via tma logs.

  4. Your app is live. Once the deployment finishes, your Mini App is available at:

    https://my-first-app.tma.sh

    If a production bot is registered, its Web App URL is automatically updated to point at the production deployment.

When you push to main, TMA.sh runs the following pipeline:

  1. GitHub webhook — TMA.sh receives the push event.
  2. Build container — a clean environment runs your project’s configured install and build commands (defaults to npm install and npm run build for newly created dashboard projects unless you change them).
  3. Upload assets — the build output is uploaded to the global CDN.
  4. Update bot URL — if a production bot is registered, its Web App URL is pointed at the new deployment.
  5. Ready — your app is live and serving traffic.

If you have a server/api/index.ts file, TMA.sh also bundles and deploys your API routes to my-first-app--api.tma.sh.

Each deployment moves through these stages:

StatusMeaning
queuedPush received, waiting for a build slot.
buildingDependencies are being installed and the project is being built.
deployingBuild output is being uploaded to the CDN and bot URL is being updated.
readyDeployment is live and serving traffic.
failedSomething went wrong. Check the build logs with tma logs.
cleanedDeployment assets have been cleaned up (old deployments).
purgedDeployment has been permanently removed.

By default, every push to main triggers a deployment. You can toggle auto-deploy on or off in your project settings on the dashboard.

When auto-deploy is off, use tma deploy to deploy manually.

Your Mini App is live. From here, you can: