Implementation
Initializing the login flow
To authenticate users with Privy’s built-in UIs, see UI components. For whitelabel implementations, useinitOAuth from the useLoginWithOAuth hook to trigger the OAuth login flow.OAuthProviderType
required
The OAuth provider to use for authentication. Valid values are:
'google', 'apple', 'twitter',
'github', 'discord', 'linkedin', 'spotify', 'tiktok', 'instagram', 'telegram', 'line'.boolean
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Usage
Flow state
Thestate variable returned by useLoginWithOAuth tracks the OAuth flow:Callbacks
Pass optional callbacks touseLoginWithOAuth:User
The user object returned after successful login.
boolean
Whether the user is a new user or an existing user.
boolean
Whether the user was already authenticated before the OAuth flow.
string
The login method used (‘google’, ‘apple’, etc.).
LinkedAccount
The linked account if the user was already authenticated.
Security and tokens
Google OAuth may not work in in-app browsers due to Google’s restrictions in embedded webviews.- Configure allowed OAuth redirect URLs to restrict post-login redirects.
- Access user OAuth and refresh tokens via the useOAuthTokens hook when using your own OAuth credentials.
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.
Telegram Mini App seamless login
Privy supports zero-click authentication for users who open your app from within a Telegram Mini App. When a user opens your app via a Mini App link, Privy detects the Telegram context and authenticates them automatically — nologin() call required.
Setup
- Configure Telegram OAuth credentials and enable seamless authentication in the Privy Dashboard under Telegram settings.
- Send your app URL to users via a bot message or Mini App link:
t.me/your_bot/your_app).
For reference:
Client implementation
No additional client code is required. Privy automatically detects the Mini App context on load and authenticates the user. Your app can read the authenticated user as usual from theusePrivy hook once ready is true.
Configure login methods (optional)
IfloginMethods is configured in PrivyProvider, add "telegram":
Seamless linking within a Mini App
To link a Telegram account to an already-authenticated user from within a Mini App, uselinkWithOAuth:

