telegram-login-button
Installation
npm install telegram-login-button
There are also UMD builds available via unpkg:
- https://unpkg.com/telegram-login-button/dist/telegram-login-button.umd.development.js
- https://unpkg.com/telegram-login-button/dist/telegram-login-button.umd.production.js
React Telegram login button
Usage
import React from 'react'
import { render } from 'react-dom'
import TelegramLoginButton, { TelegramUser } from 'telegram-login-button'
render(
<TelegramLoginButton
botName="test"
dataOnauth={(user: TelegramUser) => console.log(user)}
/>,
document.getElementById('root')
)
API
Props
-
botName
- Required | string | your bot username without @. -
dataOnauth
- Optional | function | call back on user authentication. -
dataAuthUrl
- Optional | string | redirect to url on user authentication. -
usePic
- Optional | boolean | show user profile alongside button. defaults to false. -
className
- Optional | string | extra className to override things. defaults to undefined. -
cornerRadius
- Optional | number (in pixel) | radius of the button. defaults to undefined. -
requestAccess
- Optional | boolean | to send messages from your bot. defaults to true. -
buttonSize
- Optional | 'large' or 'medium' or 'small' | button size. defaults to large.
Either dataOnauth
or dataAuthUrl
should be given. If both are given, it uses dataAuthUrl
.
License
MIT