The Mini App frontend lives in webapp/ and is built with React 18, TypeScript, Vite, i18next, and Zustand. The current app renders a single ProfilePage and uses the Telegram WebApp SDK to read theme and initData.
webapp/src/main.tsxboots React and loads i18n.webapp/src/App.tsxrenders the root layout andProfilePage.
// webapp/src/App.tsx
const App: FC = () => {
const { colorScheme } = useTelegram();
return (
<div className={`app app--${colorScheme}`}>
<ProfilePage />
</div>
);
};useTelegram wraps the SDK and exposes helpers:
const { isReady, themeParams, hapticFeedback, sendData } = useTelegram();It also applies Telegram theme variables to CSS custom properties.
User data is stored in useUserStore:
const { user, isLoading, error, setUser } = useUserStore();The API client automatically injects initData:
const response = await authApi.validate();The base URL comes from VITE_API_URL or falls back to /api.
Translations live in webapp/public/locales/ and are loaded with i18next:
import { useTranslation } from "react-i18next";
const { t } = useTranslation();Supported languages are configured in webapp/src/i18n.ts.
CSS lives in webapp/src/styles/ and uses Telegram theme variables:
:root {
--tg-theme-bg-color: #ffffff;
--tg-theme-text-color: #111827;
}Create a new page component:
// webapp/src/pages/SettingsPage.tsx
export const SettingsPage: FC = () => {
return <div>Settings</div>;
};Render it from App.tsx or add a router (not included by default).
Symptoms: White screen in Telegram.
Cause: JS error or missing initData.
Solution: Check console logs and open the app inside Telegram.
Symptoms: App uses default colors only.
Cause: Telegram WebApp SDK not ready.
Solution: Ensure useTelegram() is called in App.tsx.
- DO call
tg.ready()before accessing SDK features. - DO keep API calls in hooks or services, not inside components directly.
- DO handle
isLoadinganderrorstates. - DO keep translations up to date for all languages.
- Add pages in Adding Features
- Learn about Theming
- Review API Reference