@twa-dev/backbutton
v0.0.7
Published
React component for Telegram Web Apps (TWA) Back Button
Downloads
51
Readme
DEPRECATED
BackButton
moved to @twa-dev/sdk. This repo and corresponding npm-package are deprecated.
BackButton
React component for Telegram Web Apps (TWA) Back Button.
npm i @twa-dev/backbutton
Motivation
TWA SDK contains an interface that controls BackButton. It's written in imperative way:
const BackButton = window.Telegram.WebApp.BackButton;
BackButton.show();
BackButton.onClick(() => window.history.back());
It's not the best way to write code, especially if you use libraries like React.
This package exports React component that wraps TWA BackButton SDK:
import BackButton from '@twa-dev/backbutton';
<BackButton onClick={() => window.history.back()} />