Introduction
Build Telegram bots with React components, hooks, and file-style routing — powered by Teact and grammY.
Teact is in alpha — the API may change before 1.0
Teact lets you ship Telegram bots using the same mental model as React apps: components, hooks, routing, and JSX, compiled and run with Bun.
function Counter() {
const [count, setCount] = useState(0);
return (
<Message text={`Count: ${count}`}>
<InlineKeyboard columns={2}>
<Button text="−1" onClick={() => setCount((c) => c - 1)} />
<Button text="+1" onClick={() => setCount((c) => c + 1)} />
</InlineKeyboard>
</Message>
);
}Install & scaffold
Create a project and add your bot token.
Quick start
From zero to a running bot in a few minutes.
Router & navigation
createRouter, guards, and useNavigate.
Deploy to the edge
Cloudflare Workers & serverless with bot.fetch().
What you can build
- Messages & keyboards — inline and reply keyboards with
<Button>,<InlineKeyboard>,<ReplyKeyboard>. - Routing —
createRouterwith params,beforeLoadguards, and navigation modes (push,replace,stack,dismiss). - Flows — multi-step conversations and schema-driven forms.
- Platform features — streaming text, i18n, payments (
useInvoice), auth plugins, session storage, and events viauseOn. - Deploy anywhere — long-running polling or serverless via a web-standard
bot.fetch(request)handler.
Packages at a glance
| Package | Role |
|---|---|
@teactjs/core | The engine — createBot, router, hooks, plugin host, reconciler, and re-exported React |
@teactjs/ui | Components — Message, keyboards, media, polls, formatting |
@teactjs/telegram | grammY-based adapter (polling & webhook) + conversationsPlugin / streamPlugin |
@teactjs/plugin-sdk | definePlugin — author your own plugins |
@teactjs/storage | Persistent storage plugin (file/memory drivers; bring your own for KV/Redis) |
@teactjs/testing | MockAdapter, renderBot |
@teactjs/cli / create-teact | Dev server, build, deploy, and scaffolding |
The 0.2.0 rewrite folded the old @teactjs/react, @teactjs/runtime, and @teactjs/renderer
packages into @teactjs/core. Import components from @teactjs/ui and everything else
from @teactjs/core.
Next steps
- Follow Installation and Quick start.
- Skim Configuration for
teact.config.ts, plugins, and sessions. - Deep-dive the Guides in the sidebar — routing, components, conversations, deployment, and more.