Enable Telegram authentication in the Privy
Dashboard before implementing
this feature.
Telegram does not support
.xyz
domains for authentication. If your application uses a .xyz
domain, Telegram will not send authentication messages during the login flow. To work around this
limitation, you must use a different top-level domain (TLD) for your application, or set up a
separate domain with a different TLD specifically for handling Telegram authentication.Privy also enables seamless login within Telegram, so users can zero-click authenticate to your
Telegram bot or mini-app. Check out our recipe for setting up seamless login with
Telegram.
- React
To authenticate your users with Privy’s out of the box UIs, check out UI components here.
useLoginWithTelegram
hook.Usage
Before using the
useLoginWithTelegram
hook, ensure that Telegram is enabled in Socials tab of the Login Methods page on the the Privy dashboardTracking Flow State
Track the state of the Telegram authentication flow via thestate
variable returned by the
useLoginWithTelegram
hook.The current state of the Telegram authentication flow.
The error that occurred during the Telegram authentication flow.
Callbacks
You can optionally pass callbacks into theuseLoginWithTelegram
hook to run custom logic after a successful login or to handle errors that occur during the flow.onComplete
Parameters
The user object corresponding to the authenticated user.
Whether the user is a new user or an existing user.
Whether the user entered the application already authenticated.
The method used by the user to login.
The account corresponding to the loginMethod used.
onError
Parameters
The error that occurred during the login flow.