Privy offers the ability to sign up and log users in using OAuth providers. Users can sign in with familiar flows on Google, Apple, Twitter, Github, Discord, LinkedIn, TikTok, Spotify, Instagram, and LINE.
Login with OAuth is the onboarding flow your users are used to, integrated into your application in just a few lines of code.
The SDK supports OAuth login with . For all other OAuth providers, you can use JWT-based authentication.
Use initOAuth
from the useLoginWithOAuth
hook to trigger the OAuth login flow.
The OAuth provider to use for authentication. Valid values are: 'google'
, 'apple'
, 'twitter'
,
'github'
, 'discord'
, 'linkedin'
, 'spotify'
, 'tiktok'
, 'instagram'
, 'line'
.
If set to true, the OAuth flow will only allow users to log in with existing accounts and prevent new account creation.
Track the state of the OAuth flow via the state
variable returned by the useLoginWithOAuth
hook.
The current state of the OAuth flow.
The error that occurred during the OAuth flow (only present when status is ‘error’).
You can optionally pass callbacks to the useLoginWithOAuth
hook to run custom logic after a successful login or to handle errors.
onSuccess
The user object returned after successful login.
Whether the user is a new user or an existing user.
Whether the user was already authenticated before the OAuth flow.
The login method used (‘google’, ‘apple’, etc.).
The linked account if the user was already authenticated.
onError
The error that occurred during the OAuth flow.
We recommend configuring allowed OAuth redirect URLs to restrict where users can be redirected after they log in with an external OAuth provider. Learn more here!