Skip to content

Updating user emails ‚Äč

To prompt users to change their email, developers can use the updateEmail method from the usePrivy hook.

tsx
const {updateEmail} = usePrivy();

The updateEmail method does not accept any parameters.

When invoked, this method will open the Privy modal and guide the user through updating their existing email to a new one. If a user does already not have an email account, Privy will throw an error indicating such.

Users can encounter errors if they attempt to go through this flow without an existing email account, or if the email address 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 email account will be maintained.

Below is an example button for prompting a user to update their email address:

tsx
import {usePrivy} from '@privy-io/react-auth';

function Page() {
  const {ready, authenticated, user, updateEmail} = usePrivy();

  return (
    <button onClick={updateEmail} disabled={!ready || !authenticated || !user.email}>
      Update your email
    </button>
  );
}