vue-tg is a lightweight package designed for seamless integration of Telegram Mini Apps and Telegram Widgets into Vue 3 applications. Currently at version 0.10.0, it maintains an active release cadence, frequently updating to support the latest Telegram Bot API versions, such as 9.5. Key differentiators include its use of Vue 3 composables for reactive interaction with the Telegram client, full TypeScript type safety, and an innovative API that enforces runtime feature support checks to prevent errors on clients with outdated Bot API versions. It also provides async/await support for methods, eliminating callback hell, and includes ready-to-use Vue components for common Mini App UI elements like MainButton and BackButton, streamlining development workflows.
npm install vue-tgVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the `MainButton` component to trigger an alert via the `usePopup` composable within a Vue 3 Telegram Mini App.
Always use `isVersionAtLeast()` checks (e.g., `deviceStorage.isVersionAtLeast('9.0')`) before utilizing features, or configure a minimum required Bot API version globally as per the documentation to disable warnings.Add `<script src="https://telegram.org/js/telegram-web-app.js"></script>` to your `index.html`'s `<head>` section.
Consult the official documentation for each specific composable to ensure the correct import path is used. Pay close attention to examples like `import { usePopup } from 'vue-tg/latest'`.Maintain awareness of `vue-tg` release notes and Telegram Bot API updates. Regularly update the package and review your codebase for necessary adjustments, especially when upgrading to new major or minor versions.
Implement a version check before using the feature: `if (deviceStorage.isVersionAtLeast('9.0')) { deviceStorage.getItem('token') }`. Alternatively, configure a minimum required Bot API version globally if all target clients are known to support it.Verify that the import statement matches the exact path specified in the `vue-tg` documentation for the given symbol (e.g., `import { usePopup } from 'vue-tg/latest'`). Ensure your bundler supports subpath exports if applicable.