Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

EmailAddress

The EmailAddress object is a model around an email address. Email addresses are used to provide identification for users.

Email addresses must be verified to ensure that they can be assigned to their rightful owners. The EmailAddress object holds all necessary state around the verification process.

The verification process always starts with the EmailAddress.prepareVerification() method, which will send a one-time verification code via an email message. The second and final step involves an attempt to complete the verification by calling the EmailAddress.attemptVerification() method, passing the one-time code as a parameter.

Finally, email addresses can be linked to other identifications.

Properties

NameTypeDescription
idstringA unique identifier for this email address.
emailAddressstringThe value of this email address.
verificationVerificationAn object holding information on the verification of this email address.
linkedToArray<{id: string, type: string}>An array of objects containing information about any identifications that might be linked to this email address.

Methods

create()

Creates a new email address for the current user.

function create(): Promise<EmailAddress>;

destroy()

Deletes this email address.

function destroy(): Promise<void>;

toString()

Returns the value for this email address. Can also be accessed via the EmailAddress.emailAddress attribute.

function toString(): string;

Sets up an email verification with email link flow. Calling createEmailLinkFlow() will return two functions.

The first function is async and starts the email link flow, preparing a email link verification. It sends the email link email and starts polling for verification results. The signature is startEmailLinkFlow({ redirectUrl: string }) => Promise<EmailAddress>.

The second function can be used to stop polling at any time, allowing for full control of the flow and cleanup. The signature is cancelEmailLinkFlow() => void.

function createEmailLinkFlow(): { startEmailLinkFlow: (params: StartEmailLinkFlowParams) => Promise<EmailAddress>; cancelEmailLinkFlow: () => void; };

createEmailLinkFlow returns an object with two functions:

NameTypeDescription
startEmailLinkFlow(params: StartEmailLinkFlowParams) => Promise<EmailAddress>Function to start the email link flow. It prepares a email link verification and polls for the verification result.
cancelEmailLinkFlow() => voidFunction to cleanup the email link flow. Stops waiting for verification results.
NameTypeDescription
redirectUrlstringThe email link target URL. Users will be redirected here once they click the email link from their email.

Additional methods

In addition to the methods listed above, the EmailAddress class also has the following methods:

Validation

Last updated on April 19, 2024

What did you think of this content?

Clerk © 2024