- Standard login: Users authenticate via Telegram’s login widget from a regular web environment.
- Seamless login: Users authenticate automatically (zero-click) when accessing your app from within a Telegram bot or Mini App.
Configure Telegram
Create a Telegram bot
Follow this guide to create a Telegram bot. After creating the bot, set your domain using the/setdomain command in the @BotFather chat.
Provide the following to Privy via the Dashboard:
- Bot token (e.g.,
1234567890:AzByCxDwEvFuGtHsIr1k2M4o5Q6s7U8w9Y0) - Bot handle (e.g.,
@MyBot_bot)
Domain requirements
- Your domain must be configured as the bot’s allowed domain.
- Telegram does not support
.xyzdomains. If your application uses a.xyzdomain, use a different top-level domain for Telegram authentication.
Since the bot’s allowed domain must match your app’s domain, use a tunneling tool for local
development such as Cloudflare
tunnels or
ngrok.
Content Security Policy
If your app enforces CSP, add these directives:script-src: allowhttps://telegram.org(Telegram’s widget script)frame-src: allowhttps://oauth.telegram.org(Telegram’s widget iframe)
Secure your bot secret
Per-client configuration
Privy supports overriding Telegram bot credentials on a per-app-client basis. This is useful when different clients (e.g., a web app and a Mini App) need to authenticate through different Telegram bots.How it works
Each app client can have its own Telegram configuration that takes precedence over the app-level default. If no client-specific override is set, the app-level configuration is used as a fallback.Configure in the Dashboard
Navigate to App clients > select your client > Telegram credentials override and configure:
To remove the override and revert to the app-level default, select Remove override.
Standard login
To authenticate users with Privy’s out-of-the-box UIs, check out UI
components.
useLoginWithTelegram hook to authenticate users with Telegram.Usage
Tracking 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
Pass callbacks into theuseLoginWithTelegram hook to run custom logic after a successful login or to handle errors.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.
Resources
React starter repo
Get started with React and Privy.
Next.js starter repo
Get started with Next.js and Privy.
Whitelabel starter repo
Get started with a whitelabel Privy integration.
Seamless login
Seamless login enables zero-click authentication for users who access your app from within a Telegram bot or Mini App. Privy automatically logs the user in without requiring them to interact with a login widget.How it works
When a user opens your app via a Telegram bot command or Mini App link, Privy detects the Telegram context and authenticates the user automatically. Your app does not need to calllogin from the usePrivy hook.
Enable seamless login
- Enable seamless authentication in the Privy Dashboard under Telegram settings (or per-client via the app client Telegram override).
- Send your website URL via one of these Telegram bot methods:
t.me/your_bot/your_app).
For reference:
Configure login methods (optional)
IfloginMethods is configured client-side in the PrivyProvider, add "telegram" to the list. Client-side login method configuration is only necessary to restrict logins to a subset of those configured in the Dashboard.
Linking Telegram accounts
Link Telegram
Use thelinkTelegram method from the usePrivy hook to add Telegram accounts to a user, and the useUnlinkTelegram hook to remove them.
Seamless linking within a Mini App
Within a Telegram Mini App, link a Telegram account seamlessly by passinglaunchParams:
TelegramAccount type
Theuser object contains information about all accounts a user has linked with Privy.
- Use
user.linkedAccountsto get all linked accounts - Use
user.telegramto get the Telegram account
TelegramAccount extends LinkedAccount

