Teact

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>
  );
}

What you can build

  • Messages & keyboards — inline and reply keyboards with <Button>, <InlineKeyboard>, <ReplyKeyboard>.
  • Routing — createRouter with params, beforeLoad guards, 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 via useOn.
  • Deploy anywhere — long-running polling or serverless via a web-standard bot.fetch(request) handler.

Packages at a glance

PackageRole
@teactjs/coreThe engine — createBot, router, hooks, plugin host, reconciler, and re-exported React
@teactjs/uiComponents — Message, keyboards, media, polls, formatting
@teactjs/telegramgrammY-based adapter (polling & webhook) + conversationsPlugin / streamPlugin
@teactjs/plugin-sdkdefinePlugin — author your own plugins
@teactjs/storagePersistent storage plugin (file/memory drivers; bring your own for KV/Redis)
@teactjs/testingMockAdapter, renderBot
@teactjs/cli / create-teactDev 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

  1. Follow Installation and Quick start.
  2. Skim Configuration for teact.config.ts, plugins, and sessions.
  3. Deep-dive the Guides in the sidebar — routing, components, conversations, deployment, and more.

On this page