协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
tg-miniapp【开发与工程】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.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Battle-tested solutions for common Telegram Mini App issues.
// Use reactive hook - values are async and context-dependent
const safeArea = useSafeAreaInset(); // from references/hooks.ts
<div style={{ paddingTop: safeArea.top }}>Header</div>
Telegram applies transform to container. Use createPortal:
import { createPortal } from 'react-dom';
createPortal(<Modal />, document.body);
Use @telegram-apps/sdk, not raw WebApp:
import { onBackButtonClick, showBackButton } from '@telegram-apps/sdk';
onBackButtonClick(handleBack);
/setinline → select botsavePreparedInlineMessage → returns prepared_message_idWebApp.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.
// WRONG: renders literal "0"
{count && <span>{count}</span>}
// CORRECT
{count > 0 && <span>{count}</span>}
Before shipping, test: