1.0.5 • Published 2 years ago

@use-telegram-auth/hook v1.0.5

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

@use-telegram-auth/hook

React hook wrapper around @use-telegram-auth/client

Installation

npm i @use-telegram-auth/hook

Usage

Using default options:

import useTelegramAuth from "@use-telegram-auth/hook";

const BOT_ID = "123";

const { onAuth, isLoading } = await useTelegramAuth(BOT_ID);

// Validate the result on server-side!

<button onClick={() => onAuth()}>
  {isLoading ? "Authenticating..." : "Login"}
</button>;

Tweaking some options:

import useTelegramAuth from "@use-telegram-auth/hook";

const BOT_ID = "123";

const { onAuth, isLoading } = await useTelegramAuth(BOT_ID, {
  windowFeatures: { popup: true },
});

// Validate the result on server-side!

<button onClick={() => onAuth()}>
  {isLoading ? "Authenticating..." : "Login"}
</button>;

Using callbacks:

import useTelegramAuth from "@use-telegram-auth/hook";

const BOT_ID = "123";

const { onAuth, isLoading } = await useTelegramAuth(
  BOT_ID,
  {
    windowFeatures: { popup: true },
  },
  {
    onSuccess: (result) => {
      // Send the result to the server
    },
  }
);

// Validate the result on server-side!

<button onClick={() => onAuth()}>
  {isLoading ? "Authenticating..." : "Login"}
</button>;
1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago