Skip to content

A powerful and feature-rich TypeScript-based NPM package for interacting with Telegram Mini Apps. This package provides a seamless way to integrate Telegram Mini Apps into your projects, offering a wide range of functionalities to enhance user experience. πŸš€

Notifications You must be signed in to change notification settings

antontuzov/telegram-mini-apps-2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Telegram Mini Apps NPM Package πŸ“¦

A powerful and feature-rich TypeScript-based NPM package for interacting with Telegram Mini Apps. This package provides a seamless way to integrate Telegram Mini Apps into your projects, offering a wide range of functionalities to enhance user experience. πŸš€


Features ✨

  • Core Methods: Ready, expand, close, and more. πŸ› οΈ
  • UI Controls: BackButton, MainButton, SettingsButton. πŸŽ›οΈ
  • Haptic Feedback: Provide tactile feedback to users. πŸ“³
  • Cloud Storage: Store and retrieve user-specific data. ☁️
  • Biometric Authentication: Integrate fingerprint and face recognition. πŸ”’
  • Location Manager: Access device location. 🌍
  • Sensors: Accelerometer, Gyroscope, and Device Orientation. πŸ“‘
  • QR Scanner: Scan QR codes directly in the app. πŸ“·
  • Clipboard: Read text from the clipboard. πŸ“‹
  • Sharing: Share media to stories and messages. πŸ“€
  • Fullscreen Mode: Enter and exit fullscreen mode. πŸ–₯️
  • Orientation Control: Lock and unlock screen orientation. πŸ”„
  • Home Screen Integration: Add the app to the home screen. 🏠
  • Event Handling: Listen to and manage app events. 🎧

Installation βš™οΈ

To install the package, run the following command:

npm install telegram-mini-apps-2.0

Usage πŸ› οΈ

Importing the Package

import { TelegramWebApp } from 'telegram-mini-apps-2.0';

// Initialize the app
TelegramWebApp.ready();

// Set header color
TelegramWebApp.setHeaderColor('#ffffff');

// Show the back button
TelegramWebApp.BackButton.show();

// Set main button text
TelegramWebApp.MainButton.setText('Submit');

// Handle main button click
TelegramWebApp.MainButton.onClick(() => {
  console.log('Main button clicked!');
});

// Provide haptic feedback
TelegramWebApp.HapticFeedback.impactOccurred('medium');

// Get device location
TelegramWebApp.LocationManager.getLocation((location) => {
  console.log('Location:', location);
});

// Scan QR code
TelegramWebApp.QRScanner.show({ text: 'Scan QR Code' }, (data) => {
  console.log('QR Code data:', data);
});

// Read text from clipboard
TelegramWebApp.Clipboard.readText((text) => {
  console.log('Clipboard text:', text);
});

// Share media to story
TelegramWebApp.Share.shareToStory('https://example.com/media');

// Enter fullscreen mode
TelegramWebApp.Fullscreen.requestFullscreen();

// Lock screen orientation
TelegramWebApp.Orientation.lockOrientation();

// Add app to home screen
TelegramWebApp.HomeScreen.addToHomeScreen();

// Listen to events
TelegramWebApp.Events.onEvent('viewportChanged', (data) => {
  console.log('Viewport changed:', data);
});

Modules πŸ“š

Core Modules

BackButton: Control the back button in the Mini App header. ↩️

MainButton: Manage the main button at the bottom of the Mini App. 🎯

HapticFeedback: Provide haptic feedback for user interactions. πŸ“³

CloudStorage: Store and retrieve user-specific data. ☁️

BiometricManager: Handle biometric authentication. πŸ”’

LocationManager: Access and manage device location. 🌍

Accelerometer: Access accelerometer data. πŸ“‘

DeviceOrientation: Access device orientation data. πŸ”„

Gyroscope: Access gyroscope data. πŸŒ€

SettingsButton: Control the settings button in the Mini App. βš™οΈ

Utility Modules

Invoice: Open and manage invoices. πŸ’³

QRScanner: Scan QR codes. πŸ“·

Clipboard: Read text from the clipboard. πŸ“‹

Share: Share media to stories and messages. πŸ“€

Fullscreen: Manage fullscreen mode. πŸ–₯️

Orientation: Control screen orientation. πŸ”„

HomeScreen: Add the app to the home screen. 🏠

Contributing 🀝

We welcome contributions! If you'd like to contribute to this project, please follow these steps:

Fork the repository. 🍴
Create a new branch for your feature or bugfix. 🌿
Commit your changes. πŸ’Ύ
Push your branch to your fork. πŸš€
Submit a pull request. πŸŽ‰

License πŸ“„

This project is licensed under the MIT License. See the LICENSE file for details.

Support πŸ’¬

If you have any questions or need support, feel free to open an issue on GitHub or reach out to us at antontuzovj@gmail.com

Acknowledgments πŸ™

Thanks to Telegram for providing the Mini Apps platform. πŸ“±

Special thanks to all contributors who helped make this project better. 🌟

Happy Coding! πŸŽ‰πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

About

A powerful and feature-rich TypeScript-based NPM package for interacting with Telegram Mini Apps. This package provides a seamless way to integrate Telegram Mini Apps into your projects, offering a wide range of functionalities to enhance user experience. πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published