React component for Telegram Web Apps (TWA) Back Button.
npm i @twa-dev/sdk
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/sdk/react';
<BackButton onClick={() => window.history.back()} />