SignUp
The SignUp object contains the state of the current sign-up that the user has initiated.
Overview
The SignUp object holds the state of the current sign up and provides helper methods to navigate and complete the sign up flow. Once a sign up is complete, a new user is created.
There are two important steps that need to be done in order for a sign up to be completed:
- Supply all the required fields. The required fields depend on your instance settings.
- Verify contact information. Some of the supplied fields need extra verification. These are the email address and phone number.
The above steps can be split into smaller actions (e.g. you don't have to supply all the required fields at once) and can done in any order. This provides great flexibility and supports even the most complicated sign up flows. The SignUp object provides a number of helper methods to achieve the above.
Also, the attributes of the SignUp object can basically be grouped into three categories:
- Those that contain information regarding the sign-up flow and what is missing in order for the sign-up to complete. For more information on these, check our detailed sign-up flow guide.
- Those that hold the different values that we supply to the sign-up. Examples of these are username, emailAddress, firstName, etc.
- Those that contain references to the created resources once the sign-up is complete, i.e. createdSessionId and createdUserId.
Attributes
Name | Type | Description |
---|---|---|
status | string | The status of the current sign-up. It can take the following values:
|
requiredFields | string[] | An array of all the required fields that need to be supplied and verified in order for this sign-up to be marked as complete and converted into a user. |
optionalFields | string[] | An array of all the fields that can be supplied to the sign-up, but their absence does not prevent the sign-up from being marked as complete. |
missingFields | string[] | An array of all the fields whose values are not supplied yet but they are mandatory in order for a sign-up to be marked as complete. |
unverifiedFields | string[] | An array of all the fields whose values have been supplied, but they need additional verification in order for them to be accepted. |
supportedExternalAccounts | string[] | An array of all the external accounts that are supported in the current sign-up, e.g. |
verifications | SignUpVerificationsResource | An object that contains information about all the verifications that are in-flight. |
username | string | null | The username supplied to the current sign-up. |
emailAddress | string | null | The email address supplied to the current sign-up. |
phoneNumber | string | null | The phone number supplied to the current sign-up. |
web3Wallet | string | null | The Web3 wallet public address supplied to the current sign-up. In Ethereum, the address is made up of |
passwordEnabled | boolean | The value of this attribute is true if a password was supplied to the current sign-up. |
firstName | string | null | The first name supplied to the current sign-up. |
lastName | string | null | The last name supplied to the current sign-up. |
unsafeMetadata | {[string]: any} | null | Metadata that can be read and set from the frontend. |
createdSessionId | string | null | The identifier of the newly-created session. This attribute is populated only when the sign-up is complete. |
createdUserId | string | null | The identifier of the newly-created user. This attribute is populated only when the sign-up is complete. |
Methods
create(params)
create(params: SignUpParams) => Promise<SignUpResource>
This method initiates a new sign-up flow. It creates a new SignUp object and de-activates any existing SignUp that the client might already had in progress.
The form of the given params
depends on the configuration of the instance. Choices on the instance settings affect which options are available to use.
The create
method will return a promise of the new SignUp object. This sign up might be complete if you supply the required fields in one go. However, this is not mandatory. Our sign-up process provides great flexibility and allows users to easily create multi-step sign-up flows.
Parameters
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
update(params)
update(params: SignUpParams) => Promise<SignUpResource>
This method is used to update the current sign up.
As with create
, the form of the given params
depends on the configuration of the instance.
Parameters
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
prepareVerification(strategy)
prepareVerification(strategy: SignUpVerificationStrategy) => Promise<SignUpResource>
The prepareVerification
is used to initiate the verification process for a field that requires it. As mentioned above, there are two fields that need to be verified:
- emailAddress: The email address can be verified via an email code. This is a one-time code that is sent to the email already provided to the SignUp object. The
prepareVerification
sends this email. - phoneNumber: The phone number can be verified via a phone code. This is a one-time code that is sent via an SMS to the phone already provided to the SignUp object. The
prepareVerification
sends this SMS.
Parameters
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
attemptVerification(params)
attemptVerification(params: SignUpVerificationAttemptParams) => Promise<SignUpResource>
Attempts to complete the in-flight verification process that corresponds to the given strategy. In order to use this method, you should first initiate a verification process by calling SignUp.prepareVerification.
Depending on the strategy, the method parameters could differ.
Parameter
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
prepareEmailAddressVerification()
prepareEmailAddressVerification() => Promise<SignUpResource>
Helper method that allows you to initiate a verification process for an email address. It basically sends a one-time code to the email address already supplied to the current sign up.
This is equivalent to calling SignUp.prepareVerification("email_code")
.
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
attemptEmailAddressVerification(params)
attemptEmailAddressVerification(params: VerificationAttemptParams) => Promise<SignUpResource>
Helper method that attempts to complete the verification process for an email address. It basically verifies that the supplied code is the same as the one-time code that was sent to the email address during the prepare verification phase.
This is equivalent to calling SignUp.attemptVerification({strategy: "email_code", ...params})
.
Parameter
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
createMagicLinkFlow()
createMagicLinkFlow() => CreateMagicLinkFlowParams<StartMagicLinkFlowParams, SignUpResource>
Sets up a sign up with magic link flow. Calling createMagicLinkFlow()
will return two functions.
The first function is async and starts the magic link flow, preparing a magic link verification. It sends the magic link email and starts polling for verification results. The signature is startMagicLinkFlow({ redirectUrl: string }) => Promise<SignUpResource>
.
The second function can be used to stop polling at any time, allowing for full control of the flow and cleanup. The signature is cancelMagicLinkFlow() => void
.
Returns
Type | Description |
---|---|
CreateMagicLinkFlowReturn<StartMagicLinkFlowParams, SignUpResource> | This method returns two functions. One to start the magic link flow and the other to cancel waiting for the results. |
preparePhoneNumberVerification()
preparePhoneNumberVerification() => Promise<SignUpResource>
Helper method that allows you to initiate a verification process for a phone number. It basically sends a one-time code to the phone number already supplied to the current sign up.
This is equivalent to calling SignUp.prepareVerification("phone_code")
.
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
attemptPhoneNumberVerification(params)
attemptPhoneNumberVerification(params: VerificationAttemptParams) => Promise<SignUpResource>
Helper method that attempts to complete the verification process for a phone number. It basically verifies that the supplied code is the same as the one-time code that was sent to the phone number during the prepare verification phase.
This is equivalent to calling SignUp.attemptVerification({strategy: "phone_code", ...params})
.
Parameter
Name | Description |
---|---|
params |
Returns
Type | Description |
---|---|
Promise<SignUpResource> | This method returns a |
prepareWeb3WalletVerification()
prepareWeb3WalletVerification() => Promise<SignUpResource>
Helper method that allows you to initiate a verification process for a web3 wallet public address. It sends the public address to the server and expects a nonce that will need to be signed.
This is equivalent to calling SignUp.prepareVerification("web3_metamask_signature")
.
attemptWeb3WalletVerification()
attemptPhoneNumberVerification() => Promise<SignUpResource>
Helper method that attempts to complete the verification process for a web3 wallet public address. It basically verifies that the supplied code is the same as the one-time code that was sent to the phone number during the prepare verification phase.
This is equivalent to calling SignUp.attemptVerification({strategy: "web3_metamask_signature", signature: "..." })
.
authenticateWithRedirect(params)
authenticateWithRedirect(params: AuthenticateWithRedirectParams) => Promise<void>
Signs up users via OAuth, where an external account provider is used to verify the user's identity and provide certain information about the user.
Parameter
Name | Description |
---|---|
params | AuthenticateWithRedirectParams |
Returns
Type | Description |
---|---|
Promise<void> | This method returns a |
authenticateWithMetamask(params)
authenticateWithMetamask(params: AuthenticateWithMetamaskParams) => void
Starts a sign up flow that uses the Metamask browser extension to authenticate the user using their public wallet address.
Parameter
Name | Type | Description |
---|---|---|
redirectUrl | string | Full URL or path to navigate after successful sign up. |
Returns
This method has no return value
Interfaces
AuthenticateWithRedirectParams
Name | Type | Description |
---|---|---|
strategy | string | The OAuth provider that will be used for singing in. Must be one of the supported OAuthStrategy values. |
redirectUrl | string | The URL that the OAuth provider should redirect to, on successful authorization on their part. |
redirectUrlComplete | string | The URL that the user will be redirected to, after successful authorization from the OAuth provider and Clerk sign in |
SignUpParams
Name | Type | Description |
---|---|---|
firstName | string | null | The user's first name. |
lastName | string | null | The user's last name. |
password | string | null | The user's password. |
emailAddress | string | null | The user's email address. |
phoneNumber | string | null | The user's phone number. |
web3Wallet | string | null | The user's Web3 wallet public address. In Ethereum, the address is made up of |
username | string | null | The user's username. |
unsafeMetadata | {[string]: any} | null | Metadata that can be read and set from the frontend. |
invitationToken | string | null | It represents a token that was generated as part of an invitation creation. Using this token, you can auto-verify the email address that this invitation was sent to without any additional steps. |
SignUpVerificationsResource
Name | Description |
---|---|
emailAddress | |
phoneNumber | |
web3Wallet | SignUpVerificationResource |
SignUpVerificationResource
Name | Type | Description |
---|---|---|
status | string | null | The verification status. |
nextAction | string | Specifies the action that you could do next in order to complete this verification. |
supportedStrategies | string[] | An array of all strategies supported for this resource. |
strategy | string | null | The verification strategy. Possible strategy values are:
|
attempts | number | null | The number of attempts to complete the verification so far. Usually, a verification allows for maximum 3 attempts to be completed. |
expireAt | Date | null | The timestamp when the verification will expire and cease to be valid. |
error | ClerkAPIError | null | Any error that occurred during the verification process from the Clerk API. |
unsafeMetadata | {[string]: any} | null | Metadata that can be read and set from the frontend. |
invitationToken | string | null | It represents a token that was generated as part of an invitation creation. Using this token, you can auto-verify the email address that this invitation was sent to without any additional steps. |
SignUpVerificationAttemptParams
Name | Type | Description |
---|---|---|
strategy | SignUpVerificationStrategy | SignUpVerificationStrategy |
code | string | This property is applicable for strategies |
StartMagicLinkFlowParams
Name | Type | Description |
---|---|---|
redirectUrl | string | The URL to be redirected to after the magic link verification is prepared. |
VerificationAttemptParams
Name | Type | Description |
---|---|---|
code | string | This property is applicable for strategies |
Types
CreateMagicLinkFlowReturn<StartMagicLinkParams, SignUpResource>
{ startMagicLinkFlow: (params: StartMagicLinkFlowParams) => Promise<SignUpResource>, cancelMagicLinkFlow: () => void }
Name | Description |
---|---|
startMagicLinkFlow | Function that starts the magic link flow. It prepares a magic link verification and polls for the verification result. Accepts StartMagicLinkFlowParams. Returns a Promise which resolves to a SignUpResource. You can check the SignUpResource verifications for the verification result. |
cancelMagicLinkFlow | Function to cleanup the magic link flow. Stops waiting for verification results. |
SignUpVerificationStrategy
Value | Description |
---|---|
email_link | Specify email code as the verification strategy. This applies only to email addresses and is a one-time code sent to that email address. |
email_code | Specify email code as the verification strategy. This applies only to email addresses and is a one-time code sent to that email address. |
phone_code | Specify phone code as the verification strategy. This applies only to phone number and is a one-time code sent to that phone number via SMS. |
web3_metamask_signature | The verification will attempt to be completed using the user's web3 wallet public address. |
OAuthStrategy
oauth_facebook | oauth_github | oauth_google | oauth_hubspot | oauth_tiktok | oauth_gitlab | oauth_discord | oauth_twitter | oauth_twitch | oauth_linkedin | oauth_dropbox | oauth_bitbucket | oauth_microsoft | oauth_notion
Value | Description |
---|---|
oauth_facebook | Specify Facebook as the verification OAuth provider. |
oauth_github | Specify Github as the verification OAuth provider. |
oauth_google | Specify Google as the verification OAuth provider. |
oauth_hubspot | Specify HubSpot as the verification OAuth provider. |
oauth_tiktok | Specify TikTok as the verification OAuth provider. |
oauth_gitlab | Specify GitLab as the verification OAuth provider. |
oauth_discord | Specify Discord as the verification OAuth provider. |
oauth_twitter | Specify Twitter as the verification OAuth provider. |
oauth_twitch | Specify Twitch as the verification OAuth provider. |
oauth_linkedin | Specify LinkedIn as the verification OAuth provider. |
oauth_dropbox | Specify Dropbox as the verification OAuth provider. |
oauth_bitbucket | Specify Bitbucket as the verification OAuth provider. |
oauth_microsoft | Specify Microsoft as the verification OAuth provider. |
oauth_notion | Specify Notion as the verification OAuth provider. |