0.0.1-beta.1 • Published 2 years ago

@telegram-web-app/react v0.0.1-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@telegram-web-app/react

@telegram-web-app/core binding for react

Table of contents

Installation

@telegram-web-app/react required @telegram-web-app/core as a peer dependency, make sure to install it.

Using npm:

npm install @telegram-web-app/core @telegram-web-app/react

Usage

Import TelegramWebAppProvider from @telegram-web-app/react and wrap your app in it

import { TelegramWebAppProvider } from '@telegram-web-app/react';

...

<TelegramWebAppProvider>
  <App />
</TelegramWebAppProvider>

And then inside your app use useTelegramWebApp hook to get Telegram instance

import { useTelegramWebApp } from '@telegram-web-app/react';

export const App = () => {
  const telegram = useTelegramWebApp();
  ...
};

Components

TelegramWebAppProvider

React provider that exposes context to it's children components.

Props:

children

TypeRequiredDefault
ReactNodeyes

exposeInMainWorld

See @telegram-web-app/core docs

TypeRequiredDefault
booleannofalse

autoReady

Trigger or not automatically call Telegram.WebApp.ready() on app load. If you want manually call ready(), set this option to false.

TypeRequiredDefault
booleannotrue

Hooks

useTelegramWebApp

Returns ready to use Telegram instance, no additional options available.