cokia / react-telegram-web-app

React components for Telegram WebApp

Home Page:https://www.npmjs.com/package/@vkruglikov/react-telegram-web-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-telegram-web-app

React components for Telegram WebApp

npm types GitHub Actions CI License

🔴 Live Demo & Code Examples

You can try open demo telegram bot with React WebApp @react_telegram_web_app_bot.

Also, you can look demo source code.

🔧 Installation & Get started

1️⃣ Foremost, you have to do initializing web apps step, because package has dependency of Telegram Web App context.

2️⃣ Install by running: npm i @vkruglikov/react-telegram-web-app --save. Today we support React^18.

3️⃣ Try it out by writing code.

import React from 'react';
import { MainButton, useShowPopup } from '@vkruglikov/react-telegram-web-app';

const App = () => {
  const showPopup = useShowPopup();

  return (
    <>
      Some page content...
      <MainButton
        text="SHOW POPUP"
        onClick={() => {
          showPopup({
            message: "Hello, I'am showPopup handle",
          });
        }}
      />
    </>
  );
};

✨ Short Documentation

  • MainButton - The component controls the main button, which is displayed at the bottom of the Web App in the Telegram interface.
  • BackButton - This component controls the back button, which can be displayed in the header of the Web App in the Telegram interface.
  • useShowPopup - The hook that provided showPopup function that shows a native popup.
  • useHapticFeedback - This hook that provided impactOccurred, notificationOccurred and selectionChanged functions that controls haptic feedback.
  • useThemeParams - This hook that provided colorScheme and themeParams object.
  • useScanQrPopup - This hook that provided showScanQrPopup and closeScanQrPopup functions.

🛣 Roadmap

Here's what's coming up:

  • In the future, We would like to use us components also in Web application, without Telegram context.
  • All Telegram WebApp feature support.
  • Main Telegram WebApp feature support.

🥂 License

MIT

About

React components for Telegram WebApp

https://www.npmjs.com/package/@vkruglikov/react-telegram-web-app

License:MIT License


Languages

Language:TypeScript 99.5%Language:Shell 0.5%