Socket
Book a DemoInstallSign in
Socket

@twa-dev/mainbutton

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twa-dev/mainbutton

React component for Telegram Web Apps (TWA) Main Button

latest
Source
npmnpm
Version
0.0.11
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

DEPRECATED

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

MainButton

npm version

React component for Telegram Web Apps (TWA) Main Button.

npm i @twa-dev/mainbutton

Motivation

TWA SDK contains an interface that controls MainButton. It's written in imperative way:

const MainButton = window.Telegram.WebApp.MainButton;

MainButton.setText('Submit');
MainButton.show();
MainButton.onClick(() => alert('submitted'));

It's not the best way to write code, especially if you use libraries like React.

This package exports React component that wraps TWA MainButton SDK:

import MainButton from '@twa-dev/mainbutton';

<MainButton text="Submit" onClick={() => alert('submitted')} />

Demo

@MainButtonDemoBot

Codesandbox

Props

Naming is pretty straight forward and corresponds SDK props and methods:

  • text
  • color
  • textColor
  • disabled
  • progress
  • onClick

Keywords

telegram

FAQs

Package last updated on 12 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts