← 返回
沟通协作 中文

Telegram Mini App Dev

Build Telegram Mini Apps without the pain. Includes solutions for safe areas, fullscreen mode, BackButton handlers, sharing with inline mode, position:fixed issues, and React gotchas. Use when building or debugging Telegram Mini Apps, or when encountering issues with WebApp API, safe areas, or sharing.
轻松构建 Telegram Mini Apps,涵盖安全区、全屏模式、返回按钮、内联模式分享、fixed 定位及 React 陷阱等问题。适用于开发调试 Mini Apps 或解决 WebApp API、安全区及分享故障。
zenith2828
沟通协作 clawhub v1.0.1 1 版本 99892.1 Key: 无需
★ 1
Stars
📥 2,758
下载
💾 138
安装
1
版本
#bot#cloudflare-workers#components#fullscreen#hooks#inline-mode#latest#mini-app#react#resvg#safe-area#share-cards#sharing#telegram#tma#typescript#webapps

概述

Telegram Mini App Development

Battle-tested solutions for common Telegram Mini App issues.

Quick Reference

Safe Area (Fullscreen Mode)

// Use reactive hook - values are async and context-dependent
const safeArea = useSafeAreaInset(); // from references/hooks.ts
<div style={{ paddingTop: safeArea.top }}>Header</div>

position:fixed Broken

Telegram applies transform to container. Use createPortal:

import { createPortal } from 'react-dom';
createPortal(<Modal />, document.body);

BackButton Not Firing

Use @telegram-apps/sdk, not raw WebApp:

import { onBackButtonClick, showBackButton } from '@telegram-apps/sdk';
onBackButtonClick(handleBack);

Sharing with Inline Mode

  1. Enable inline mode: @BotFather → /setinline → select bot
  2. Backend calls savePreparedInlineMessage → returns prepared_message_id
  3. Frontend calls WebApp.shareMessage(prepared_message_id)

Note: prepared_message_id is single-use — prepare fresh for each share tap.

For static content, consider caching images on R2/CDN and preparing per-tap.

React "0" Rendering

// WRONG: renders literal "0"
{count && <span>{count}</span>}

// CORRECT
{count > 0 && <span>{count}</span>}

Detailed Guides

Testing Checklist

Before shipping, test:

  • [ ] Open from folder (chat list)
  • [ ] Open from direct bot chat
  • [ ] iOS device
  • [ ] Android device
  • [ ] Share flow (tap → dismiss → tap again)
  • [ ] Share to different chat types (user, group, channel)
  • [ ] Back button
  • [ ] Scroll with sticky header

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-28 13:30 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

communication-collaboration

imap-smtp-email

gzlicanyi
使用IMAP/SMTP读取和发送邮件;检查新/未读邮件、获取内容、搜索邮箱、标记已读/未读、发送带附件的邮件。支持...
★ 114 📥 52,473
communication-collaboration

Himalaya

lamelas
{"answer":"通过IMAP/SMTP管理邮件的CLI。可在终端使用 `himalaya` 收发、回复、转发、搜索及整理邮件。支持多账户与MML(MIME元语言)编写邮件。"}
★ 68 📥 45,630
communication-collaboration

Slack

steipete
当需要通过 slack 工具从 Clawdbot 控制 Slack 时使用,包括在频道或私信中回复消息或置顶/取消置顶项目。
★ 157 📥 47,748