Privy uses
mailchecker to detect temporary email
domains. To block them automatically, turn the setting on in the Privy
Dashboard.To authenticate your users with a one-time passcode (OTP) sent to their email address, use the
useLoginWithEmail hook.To authenticate your users with Privy’s out of the box UIs, check out UI components here.
Email login with OTP
When a user signs in with email, Privy sends a one-time passcode (OTP) to the provided address.Enterprise customers can customize the OTP email used for login, including the sender reply address and email branding (such as logo). Contact us to enable this for your application.
Send Code
Parameters
string
required
The email address of the user to log in.
boolean
Whether to disable the ability to sign up with the email address.
Returns
Promise<void>
A promise that resolves when the code is sent.
Login with Code
Parameters
string
required
The one-time passcode sent to the user’s email address.
Returns
Promise<void>
A promise that resolves when the user is logged in.
Usage
Tracking Flow State
Track the state of the OTP flow via thestate variable returned by the
useLoginWithEmail hook.'initial' | 'error' | 'sending-code' | 'awaiting-code-input' | 'submitting-code' | 'done'
The current state of the OTP flow.
Error | null
The error that occurred during the OTP flow.
Callbacks
You can optionally pass callbacks into theuseLoginWithEmail hook to run custom logic after a successful login or to handle errors that occur during the flow.onComplete
Parameters
User
The user object corresponding to the authenticated user.
boolean
Whether the user is a new user or an existing user.
boolean
Whether the user entered the application already authenticated.
LoginMethod | null
The method used by the user to login.
LinkedAccountWithMetadata | null
The account corresponding to the loginMethod used.
onError
Parameters
Error
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.

