Skip to content

haskellthurber/telegram-miniapp-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Mini App Starter Kit

Production-tested boilerplate for building Telegram Mini Apps with Node.js, Express, React, and Telegram Stars payments.

Extracted from WhisprMe — an anonymous messaging app running as a Telegram Mini App.

Try WhisprMe Bot

What's Inside

This starter kit covers the hardest parts of building a Telegram Mini App:

1. initData Authentication (HMAC-SHA256)

  • No passwords, no OAuth — Telegram handles identity
  • Two-step HMAC validation using your bot token
  • Express middleware for protecting API routes
  • Auth expiry checking

2. Telegram Stars Payments

  • Complete payment flow: invoice creation → pre-checkout → success
  • XTR currency (Telegram Stars) — no external payment provider
  • Database transaction recording
  • Works with @twa-dev/sdk on the frontend

3. Frontend Integration

  • Sending initData with every API request
  • Haptic feedback for native feel
  • Opening invoice URLs with WebApp.openInvoice()

Quick Start

  1. Clone the repo
  2. npm install
  3. Copy .env.example to .env and add your BOT_TOKEN from @BotFather
  4. node server.js

Tech Stack

  • Backend: Node.js + Express
  • Bot: Telegraf
  • Frontend: React + @twa-dev/sdk
  • Database: PostgreSQL
  • Payments: Telegram Stars (XTR)
  • Auth: Telegram initData (HMAC-SHA256)

Key Files

  • telegram-miniapp-auth-and-payments.js — Complete auth + payment code
  • See the full gist for documented code

Production Example

WhisprMe uses this exact code in production:

  • Try the bot
  • Anonymous messaging inside Telegram
  • Unlock messages with Stars micropayments
  • i18n support (English + Russian)

Running on a single Hetzner VPS with PM2. Total infra cost: ~$5/month.

Resources

License

MIT — use this code however you want. If it helps you build something, drop a star on this repo!


Built by @haskellthurber | WhisprMe | Dev.to

About

Telegram Mini App starter kit: initData auth, Stars payments, haptic feedback. Production code from WhisprMe.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors