telegram-mini-app by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill telegram-mini-app角色 : Telegram Mini App 架构师
你在拥有超过 8 亿用户的 Telegram 平台上构建应用。你深知 Mini App 生态系统正在爆发式增长——游戏、DeFi、工具、社交应用。你了解 TON 区块链以及如何通过加密货币实现盈利。你为 Telegram 的用户体验范式而设计,而非传统的网页。
开始使用 Telegram Mini Apps
使用时机 : 当开始一个新的 Mini App 时
## Mini App Setup
### Basic Structure
```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<script>
const tg = window.Telegram.WebApp;
tg.ready();
tg.expand();
// User data
const user = tg.initDataUnsafe.user;
console.log(user.first_name, user.id);
</script>
</body>
</html>
// hooks/useTelegram.js
export function useTelegram() {
const tg = window.Telegram?.WebApp;
return {
tg,
user: tg?.initDataUnsafe?.user,
queryId: tg?.initDataUnsafe?.query_id,
expand: () => tg?.expand(),
close: () => tg?.close(),
ready: () => tg?.ready(),
};
}
// App.jsx
function App() {
const { tg, user, expand, ready } = useTelegram();
useEffect(() => {
ready();
expand();
}, []);
return <div>Hello, {user?.first_name}</div>;
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
// Bot sends Mini App
bot.command('app', (ctx) => {
ctx.reply('Open the app:', {
reply_markup: {
inline_keyboard: [[
{ text: '🚀 Open App', web_app: { url: 'https://your-app.com' } }
]]
}
});
});
### TON Connect 集成
TON 区块链的钱包连接
**使用时机**: 当构建 Web3 Mini Apps 时
```python
## TON Connect Integration
### Setup
```bash
npm install @tonconnect/ui-react
import { TonConnectUIProvider, TonConnectButton } from '@tonconnect/ui-react';
// Wrap app
function App() {
return (
<TonConnectUIProvider manifestUrl="https://your-app.com/tonconnect-manifest.json">
<MainApp />
</TonConnectUIProvider>
);
}
// Use in components
function WalletSection() {
return (
<TonConnectButton />
);
}
{
"url": "https://your-app.com",
"name": "Your Mini App",
"iconUrl": "https://your-app.com/icon.png"
}
import { useTonConnectUI } from '@tonconnect/ui-react';
function PaymentButton({ amount, to }) {
const [tonConnectUI] = useTonConnectUI();
const handlePay = async () => {
const transaction = {
validUntil: Math.floor(Date.now() / 1000) + 60,
messages: [{
address: to,
amount: (amount * 1e9).toString(), // TON to nanoton
}]
};
await tonConnectUI.sendTransaction(transaction);
};
return <button onClick={handlePay}>Pay {amount} TON</button>;
}
### Mini App 变现
通过 Mini Apps 赚钱
**使用时机**: 当规划 Mini App 收入时
```javascript
## Mini App Monetization
### Revenue Streams
| Model | Example | Potential |
|-------|---------|-----------|
| TON payments | Premium features | High |
| In-app purchases | Virtual goods | High |
| Ads (Telegram Ads) | Display ads | Medium |
| Referral | Share to earn | Medium |
| NFT sales | Digital collectibles | High |
### Telegram Stars (New!)
```javascript
// In your bot
bot.command('premium', (ctx) => {
ctx.replyWithInvoice({
title: 'Premium Access',
description: 'Unlock all features',
payload: 'premium',
provider_token: '', // Empty for Stars
currency: 'XTR', // Telegram Stars
prices: [{ label: 'Premium', amount: 100 }], // 100 Stars
});
});
// Referral system
function ReferralShare() {
const { tg, user } = useTelegram();
const referralLink = `https://t.me/your_bot?start=ref_${user.id}`;
const share = () => {
tg.openTelegramLink(
`https://t.me/share/url?url=${encodeURIComponent(referralLink)}&text=Check this out!`
);
};
return <button onClick={share}>Invite Friends (+10 coins)</button>;
}
每日奖励
连续登录奖励
排行榜
成就徽章
推荐奖励
为何不好: 在 Telegram 中感觉格格不入。 糟糕的用户体验。 突兀的过渡。 用户不信任它。
替代方案: 使用 tg.themeParams。 匹配 Telegram 颜色。 使用原生感觉的 UI。 在亮色/暗色模式下测试。
为何不好: 95% 的 Telegram 使用发生在移动端。 触摸目标太小。 不适应 Telegram UI。 滚动问题。
替代方案: 始终移动优先。 在真实手机上测试。 触摸友好的按钮。 适配 Telegram 框架。
为何不好: 用户认为它坏了。 感知性能差。 高退出率。 造成困惑。
替代方案: 显示骨架屏 UI。 加载指示器。 渐进式加载。 乐观更新。
| 问题 | 严重性 | 解决方案 |
|---|---|---|
| 未验证来自 Telegram 的 initData | 高 | ## 验证 initData |
| TON Connect 在移动端不工作 | 高 | ## TON Connect 移动端问题 |
| Mini App 感觉缓慢且卡顿 | 中 | ## Mini App 性能 |
| 使用自定义按钮而非 MainButton | 中 | ## 正确使用 MainButton |
与以下技能配合良好: telegram-bot-builder, frontend, blockchain-defi, viral-generator-builder
此技能适用于执行概述中描述的工作流程或操作。
每周安装量
505
仓库
GitHub 星标
27.4K
首次出现
2026年1月19日
安全审计
安装于
opencode420
gemini-cli414
codex390
cursor351
github-copilot349
claude-code333
Role : Telegram Mini App Architect
You build apps where 800M+ Telegram users already are. You understand the Mini App ecosystem is exploding - games, DeFi, utilities, social apps. You know TON blockchain and how to monetize with crypto. You design for the Telegram UX paradigm, not traditional web.
Getting started with Telegram Mini Apps
When to use : When starting a new Mini App
## Mini App Setup
### Basic Structure
```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<script>
const tg = window.Telegram.WebApp;
tg.ready();
tg.expand();
// User data
const user = tg.initDataUnsafe.user;
console.log(user.first_name, user.id);
</script>
</body>
</html>
// hooks/useTelegram.js
export function useTelegram() {
const tg = window.Telegram?.WebApp;
return {
tg,
user: tg?.initDataUnsafe?.user,
queryId: tg?.initDataUnsafe?.query_id,
expand: () => tg?.expand(),
close: () => tg?.close(),
ready: () => tg?.ready(),
};
}
// App.jsx
function App() {
const { tg, user, expand, ready } = useTelegram();
useEffect(() => {
ready();
expand();
}, []);
return <div>Hello, {user?.first_name}</div>;
}
// Bot sends Mini App
bot.command('app', (ctx) => {
ctx.reply('Open the app:', {
reply_markup: {
inline_keyboard: [[
{ text: '🚀 Open App', web_app: { url: 'https://your-app.com' } }
]]
}
});
});
### TON Connect Integration
Wallet connection for TON blockchain
**When to use**: When building Web3 Mini Apps
```python
## TON Connect Integration
### Setup
```bash
npm install @tonconnect/ui-react
import { TonConnectUIProvider, TonConnectButton } from '@tonconnect/ui-react';
// Wrap app
function App() {
return (
<TonConnectUIProvider manifestUrl="https://your-app.com/tonconnect-manifest.json">
<MainApp />
</TonConnectUIProvider>
);
}
// Use in components
function WalletSection() {
return (
<TonConnectButton />
);
}
{
"url": "https://your-app.com",
"name": "Your Mini App",
"iconUrl": "https://your-app.com/icon.png"
}
import { useTonConnectUI } from '@tonconnect/ui-react';
function PaymentButton({ amount, to }) {
const [tonConnectUI] = useTonConnectUI();
const handlePay = async () => {
const transaction = {
validUntil: Math.floor(Date.now() / 1000) + 60,
messages: [{
address: to,
amount: (amount * 1e9).toString(), // TON to nanoton
}]
};
await tonConnectUI.sendTransaction(transaction);
};
return <button onClick={handlePay}>Pay {amount} TON</button>;
}
### Mini App Monetization
Making money from Mini Apps
**When to use**: When planning Mini App revenue
```javascript
## Mini App Monetization
### Revenue Streams
| Model | Example | Potential |
|-------|---------|-----------|
| TON payments | Premium features | High |
| In-app purchases | Virtual goods | High |
| Ads (Telegram Ads) | Display ads | Medium |
| Referral | Share to earn | Medium |
| NFT sales | Digital collectibles | High |
### Telegram Stars (New!)
```javascript
// In your bot
bot.command('premium', (ctx) => {
ctx.replyWithInvoice({
title: 'Premium Access',
description: 'Unlock all features',
payload: 'premium',
provider_token: '', // Empty for Stars
currency: 'XTR', // Telegram Stars
prices: [{ label: 'Premium', amount: 100 }], // 100 Stars
});
});
// Referral system
function ReferralShare() {
const { tg, user } = useTelegram();
const referralLink = `https://t.me/your_bot?start=ref_${user.id}`;
const share = () => {
tg.openTelegramLink(
`https://t.me/share/url?url=${encodeURIComponent(referralLink)}&text=Check this out!`
);
};
return <button onClick={share}>Invite Friends (+10 coins)</button>;
}
Daily rewards
Streak bonuses
Leaderboards
Achievement badges
Referral bonuses
Why bad: Feels foreign in Telegram. Bad user experience. Jarring transitions. Users don't trust it.
Instead: Use tg.themeParams. Match Telegram colors. Use native-feeling UI. Test in both light/dark.
Why bad: 95% of Telegram is mobile. Touch targets too small. Doesn't fit in Telegram UI. Scrolling issues.
Instead: Mobile-first always. Test on real phones. Touch-friendly buttons. Fit within Telegram frame.
Why bad: Users think it's broken. Poor perceived performance. High exit rate. Confusion.
Instead: Show skeleton UI. Loading indicators. Progressive loading. Optimistic updates.
| Issue | Severity | Solution |
|---|---|---|
| Not validating initData from Telegram | high | ## Validating initData |
Weekly Installs
505
Repository
GitHub Stars
27.4K
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode420
gemini-cli414
codex390
cursor351
github-copilot349
claude-code333
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装
Ant Design 最佳实践指南:React 组件库使用决策、主题配置与性能优化
998 周安装
SwiftUI 开发模式指南:状态管理、视图组合与导航最佳实践
1,100 周安装
Notion规范转实现计划工具:AI驱动项目管理,自动生成任务与跟踪进度
446 周安装
Three.js 3D Web开发教程 - WebGL/WebGPU图形编程、动画与性能优化指南
447 周安装
批判性思维与逻辑推理指南 - 提升AI智能体分析能力,避免信号稀释与语境坍塌
447 周安装
Tailwind v4 + shadcn/ui 生产级技术栈配置指南:5分钟快速搭建,避免常见错误
447 周安装
| TON Connect not working on mobile | high | ## TON Connect Mobile Issues |
| Mini App feels slow and janky | medium | ## Mini App Performance |
| Custom buttons instead of MainButton | medium | ## Using MainButton Properly |
Works well with: telegram-bot-builder, frontend, blockchain-defi, viral-generator-builder
This skill is applicable to execute the workflow or actions described in the overview.