This project is a starter for building Telegram Mini Apps using Next.js with integration Telegram bot using GrammyJS.
https://t.me/mini_app_starter_bot/app
- Next.js 16 - App Router, Server Components
- React 19
- Bun - Package manager and runtime
- Convex - Backend-as-a-Service
- Tailwind CSS v4 - Utility-first CSS framework
- Biome - Formatter and linter
- Telegram Mini App SDK
- Shadcn UI
- GrammyJS - Modern Telegram bot framework for Node.js
- Zod - TypeScript-first schema validation
- 🤖 Telegram Bot integration using GrammyJS
- 📱 Mobile-first UI with Shadcn components
- 🚀 Latest Next.js 16 features
- ⚡ Fast builds and installs with Bun
- 🎨 Modern styling with Tailwind v4
-
Install dependencies:
bun install
-
Create a bot in Telegram (via @BotFather and using the command
/newbot). -
Set the
TG_API_TOKENin.envto the API token of your bot. -
Configure a publicly accessible URL to your local machine using ngrok or cloudflare tunnel. If your public URL is http instead of https, refer to the docs to turn on test environment.
-
Configure the bot using @BotFather and the command
/newapp. Use the public URL you configured in the previous step as the "App link". This step will let you choose an App name, it can be used with the bot url to directly open the app. e.g.https://t.me/{bot_name}/{app_name}. -
Configure the bot's menu button to point to the mini app's URL.
-
Run the development server:
bun dev
-
Open the mini app via either the Mini App's URL or the clicking on the menu button in the bot.
This starter uses GrammyJS for Telegram bot integration. The bot code is located in the /bot directory.
- Webhook and long polling support
- Commands handling and menu button configuration
- Mini App data validation and secure authentication
- Integration with the Next.js backend via API routes
- Update your bot commands and settings using the BotFather
- Set up webhooks or use long polling (configurable in the bot code)
- Configure allowed updates and command handling
- Implement custom middleware for your bot's specific needs
See the GrammyJS documentation for more detailed information about bot development.