Appearance
Updating user accounts ​
Updating emails ​
To prompt users to change their email, you can use the updateEmail
method from the usePrivy
hook.
tsx
const {updateEmail} = usePrivy();
Updating phone numbers ​
To prompt users to change their phone number, you can use the updatePhone
method from the usePrivy
hook.
tsx
const {updatePhone} = usePrivy();
The updateEmail
and updatePhone
methods do not accept any parameters.
When invoked, the methods will open the Privy modal and guide the user through updating their existing accounts to a new one. If a user does already not have an email or phone account and attempt to update it, Privy will throw an error indicating such.
Users can encounter errors if they attempt to go through this flow without an existing account, or if the account they are trying to update to is already attached to another account.
INFO
In the event that a user encounters an error through the flow, their existing account will be maintained.
Below are example buttons for prompting a user to update their email address or phone number:
tsx
import {usePrivy} from '@privy-io/react-auth';
function Page() {
const {ready, authenticated, user, updateEmail, updatePhone} = usePrivy();
return (
<>
<button onClick={updateEmail} disabled={!ready || !authenticated || !user.email}>
Update your email
</button>
<button onClick={updatePhone} disabled={!ready || !authenticated || !user.phone}>
Update your phone number
</button>
</>
);
}
TIP
You can easily attach callbacks to updateEmail
or updatePhone
using the useUpdateAccount
interface! Read more here.