Overview
useVerifyEmail returns a function that submits a verification code to the server. It confirms two kinds of code:
- a code from
useSendVerificationEmailwithmode: "code", sent to the signed-in user. On success,user.isVerifiedis updated immediately in the local Redux store. - a sign-up code, sent when the project requires email verification before sign-in and you passed
emailVerification: { mode: "code" }tosignUpWithEmailAndPasswordorsignInWithEmailAndPassword. Pass theverificationIdthey returned. The account being confirmed isn’t signed in, so the signed-in user (if any) is left untouched; sign the user in afterwards. See Require Email Verification.
Usage Example
Parameters
The returned function accepts:The
verificationId returned with a sign-up code. Required to confirm one; leave it out for a code from useSendVerificationEmail. A sign-up code allows 5 wrong tries. If the ID is lost, signing in again returns it (or a new code’s, if the last email is more than 10 minutes old); after the tries run out, signing in again can send a new code with a new verificationId (at most one email every 10 minutes).Returns
The hook returns an async function that resolves with nothing (Promise<void>) once the email is verified.
On success without a
verificationId, user.isVerified is optimistically set
to true in the local Redux store immediately — no need to refetch the user.
With a verificationId, the local store is left as it is.
