0.0.7 • Published 2 years ago

@twa-dev/backbutton v0.0.7

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

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