Teleforge Starter App
Minimal onboarding example for Teleforge. It keeps the surface area small:
- one Mini App page built with
@teleforgex/weband@teleforgex/ui - one
/startbot command built with@teleforgex/bot - one root
pnpm devscript that runs the whole local stack
Quick Start
pnpm build
cd examples/starter-app
pnpm install
cp .env.example .env
pnpm dev
If BOT_TOKEN is still a placeholder, the bot runs in preview mode and logs the /start response locally so you can inspect the command wiring without Telegram credentials.
What Runs
pnpm dev: runsteleforge dev --openfor the whole local stack, including the companion bot processpnpm run dev:public: runsteleforge dev --public --livefor a Telegram-openable URLpnpm run dev:bot: runs the sample bot directly in polling mode whenBOT_TOKENis set, or preview mode otherwisepnpm doctor: runsteleforge doctor
The root pnpm build step is required once because the example consumes the local workspace packages directly.
Telegram Setup
- Create a bot with BotFather.
- Put the bot token into
.env. - Start
pnpm run dev:public. - Send
/startto the bot.
Project Layout
teleforge.app.json: Teleforge manifest used byteleforge devandteleforge doctorapps/web: single-page Mini Appapps/bot: minimal/startbot runtime, includingsrc/runtime.tsfor simulator chat execution
Annotated Walkthrough
If the sample is already running and you want to understand what you are looking at, read these files in order:
-
teleforge.app.json This is the manifest. It declares the bot command metadata, Mini App entry point, and route metadata. In this sample:
bot.commands[0].handleriscommands/startroutes[0].componentisApp
-
apps/bot/src/commands/start.ts This is the real
/starthandler. It sends theweb_appbutton that opens the Mini App. -
apps/bot/src/runtime.ts This is where the bot runtime is assembled and the
/startcommand is actually registered. The sample also exportscreateDevBotRuntime()here so the simulator can execute bot logic locally. -
apps/web/src/App.tsx This is the Mini App itself. It reads Telegram state with
useTelegram()anduseTheme(), renders the UI shell, and wires the Main Button. -
apps/web/src/main.tsx This is the normal web entry point that mounts the React app.
The important connection to understand is:
- the manifest documents the intended command and route structure
- the bot runtime imports and registers the command explicitly
- the web entry point imports and renders the app explicitly
So the manifest is the source of truth for app shape, but not a magic resolver.
What to Change First
If you want your first customization:
- change apps/web/src/App.tsx to change the visible Mini App
- change apps/bot/src/commands/start.ts to change the
/startmessage or button label - change teleforge.app.json when you add new commands, capabilities, or routes
Then read Build Your First Feature.
Notes
- The local browser flow uses the Teleforge mock bridge, so the theme toggle button works during local development without Telegram.
teleforge devcan execute the local/starthandler inside the simulator chat because the sample exportscreateDevBotRuntime()fromapps/bot/src/runtime.ts.- In real Telegram sessions, theme follows the Telegram client automatically.
- When
MINI_APP_URLis unset, Teleforge injects the current local or public dev URL into the companion bot process automatically.