Custom verification page
A custom verification page reads a token from its URL and calls verifyEmail to finish verification.
Better Auth · Module
verifyEmail completes manual email verification from a token in a custom verification link. Calling it with the token lets Better Auth verify the user's email.
The client verifies an email by calling verifyEmail with a query object containing the token from the verification URL. After the user follows the link, Better Auth marks the email as verified and can redirect to the configured callback URL; custom post-verification work can run through afterEmailVerification.
await authClient.verifyEmail({ query: { token } })| Name | Type | Description |
|---|---|---|
query.token | string | Verification token passed in the query object; the token comes from the verification URL. |
The documentation does not specify the method's response shape.
callbackURL.afterEmailVerification for application-specific work that must run immediately after successful verification.verifyEmail.import { betterAuth } from "better-auth";
export const authClient = createAuthClient();
const result = await authClient.verifyEmail({
query: {
token: "verification-token"
}
});
if (result.error) throw result.error;Pass the verification token from a custom verification URL to complete email verification.
A custom verification page reads a token from its URL and calls verifyEmail to finish verification.
An application uses the built-in verification URL so clicking the link verifies the address and redirects the user.
An application needs to perform provisioning or notifications after verification completes.
authClient.verifyEmail do?verifyEmail completes manual email verification. The client receives the token in the query object, and Better Auth uses that token to verify the email.
Follow-up: How can verification happen without calling this method directly? The user can open the generated verification URL, which verifies the email automatically and redirects to the configured callback URL.
Call authClient.verifyEmail({ query: { token } }), where token is the verification token contained in the custom verification link.
Follow-up: What should happen after verification? Configure afterEmailVerification to run custom code immediately after the email is verified.
When require email verification is enabled, users must verify their email before logging in. Verification is initiated through the configured email-sending flow, and the verification token completes it.
Follow-up: When is the sender invoked during sign-in? The documentation says sendVerificationEmail is called every time a user tries to sign in when verification is required.
sendVerificationEmailafterEmailVerificationemailVerificationcallbackURLrequireEmailVerification