Updating user accounts
To prompt users to change their email, you can use the updateEmail
method from the usePrivy
hook:
Usage
When invoked, the method will open the Privy modal and guide the user through updating their existing email to a new one. If a user does not already have an email account and attempts to update it, Privy will throw an error indicating such.
Example
In the event that a user encounters an error through the flow, their existing account will be maintained.
Callbacks
To configure callbacks for Privy’s updateEmail
and updatePhone
methods, use the useUpdateAccount
hook:
Usage
Parameters
The useUpdateAccount
hook accepts an options object with the following fields:
Optional callback to run after a user successfully updates an account.
Optional callback to run if there is an error during the update account flow, or if the user exits the flow prematurely.
Callback Details
onSuccess
If set, the onSuccess
callback will execute after a user has successfully updated either their phone or email on their Privy account.
Within this callback, you can access:
The user object with the user’s DID, linked accounts, and more.
A string indicating the type of update flow just executed for the authenticated user.
Possible values are 'email'
or 'sms'
.
An object representing the account that was just updated on the authenticated user.
onError
If set, the onError
callback will execute after a user initiates an update account attempt and there is an error, or if the user exits the update account flow prematurely.
Within this callback, you can access:
The error code with more information about the error.
A string indicating the type of update account flow just attempted for the authenticated user.
Was this page helpful?