Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@twa-dev/backbutton

twa-dev57MIT0.0.7TypeScript support: included

React component for Telegram Web Apps (TWA) Back Button

telegram, react, telegram web apps, telegram bot, bot

readme

DEPRECATED

BackButton moved to @twa-dev/sdk. This repo and corresponding npm-package are deprecated.

BackButton

npm version

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()} />

Demo

@BackButtonDemoBot

Codesandbox