User
The User object holds all of the information for a single user of your application and provides a set of methods to manage their account.
Each user has a unique authentication identifier which might be their email address, phone number, or a username.
A user can be contacted at their primary email address or primary phone number. They can have more than one registered email address, but only one of them will be their primary email address. This goes for phone numbers as well; a user can have more than one, but only one phone number will be their primary. At the same time, a user can also have one or more external accounts by connecting to social providers such as Google, Apple, Facebook, and many more.
Finally, a User object holds profile data like the user's name, profile picture, and a set of metadata that can be used internally to store arbitrary information. The metadata are split into publicMetadata and privateMetadata. Both types are set from the Backend API, but public metadata can also be accessed from the Frontend API.
The Clerk SDK provides some helper methods on the User object to help retrieve and update user information and authentication status.
Constructors
Types
Parameters for creating an external account connection.
Parameters for updating a user's profile information.
Parameters for updating a user's password.
Properties
A boolean indicating whether the user has enabled Backup codes.
A boolean indicating whether the organization creation is enabled for the user or not.
An integer indicating the number of organizations that can be created by the user. If the value is 0, then the user can create unlimited organizations. Default is null.
A boolean indicating whether the user is able to delete their own account or not.
An array of all the EmailAddress objects associated with the user. Includes the primary.
A list of enterprise accounts associated with the user.
An array of all the ExternalAccount objects associated with the user via OAuth. Note: This includes both verified & unverified external accounts.
Date when the user last signed in. May be empty if the user has never signed in.
The date on which the user accepted the legal requirements if required.
A list of OrganizationMemberships representing the list of organizations the user is member with.
A boolean indicating whether the user has a password on their account.
An array of all the PhoneNumber objects associated with the user. Includes the primary.
The unique identifier for the EmailAddress that the user has set as primary.
The unique identifier for the PhoneNumber that the user has set as primary.
Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API.
Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API.
A boolean indicating whether the user has enabled TOTP by generating a TOTP secret and verifying it via an authenticator app.
A boolean indicating whether the user has enabled two-factor authentication.
Extension property that returns a list of OAuth providers that the user has not yet connected.
Metadata that can be read and set from the Frontend API. One common use case for this attribute is to implement custom fields that will be attached to the User object. Please note that there is also an unsafeMetadata attribute in the SignUp object. The value of that field will be automatically copied to the user's unsafe metadata once the sign up is complete.
Functions
Retrieves the active sessions for the current user or the user with the given session ID.
Retrieves all sessions for the current user or the user with the given session ID.
Verifies a TOTP (Time-based One-Time Password) code to complete the TOTP setup process.
Generates backup codes for the current user's account.
Creates a new email address for the current user or the user with the given session ID.
Adds an external account for the user. A new ExternalAccount will be created and associated with the user. This method is useful if you want to allow an already signed-in user to connect their account with an external provider, such as Facebook, GitHub, etc., so that they can sign in with that provider in the future.
Creates a new passkey for the current user or the user with the given session ID.
Creates a new phone number for the current user or the user with the given session ID.
Creates a new TOTP (Time-based One-Time Password) configuration for the current user.
Deletes the current user, or the user with the given session ID, from the Clerk API.
Deletes the current user's password, or the user with the given session ID, using the Clerk API.
Deletes the current user's profile image, or the user with the given session ID, from the Clerk API.
Deletes the TOTP (Time-based One-Time Password) configuration for the current user.
Retrieves all email addresses associated with the current user or the user with the given session ID.
Retrieves the current user, or the user with the given session ID, from the Clerk API.
Retrieves all phone numbers associated with the current user or the user with the given session ID.
Update the current user's profile image, or the user with the given session ID, with the provided image data.
Updates the current user, or the user with the given session ID, with the provided parameters.
Updates the current user's password, or the user with the given session ID, using the Clerk API.