How to change email in firebase auth?

FOR FIREBASE V9 (modular) USERS:

The accepted answer will not apply to you. Instead, you can do this, i.e., import { updateEmail } and use it like any other import. The following code was copy/pasted directly from the fb docs at https://firebase.google.com/docs/auth/web/manage-users

Happy coding!

import { getAuth, updateEmail } from "firebase/auth";
const auth = getAuth();
updateEmail(auth.currentUser, "[email protected]").then(() => {
  // Email updated!
  // ...
}).catch((error) => {
  // An error occurred
  // ...
});

If someone is looking for updating a user's email via Firebase Admin, it's documented over here and can be performed with:

admin.auth().updateUser(uid, {
  email: "[email protected]"
});

You're looking for the updateEmail() method on the firebase.User object: https://firebase.google.com/docs/reference/js/firebase.User#updateEmail

Since this is on the user object, your user will already have to be signed in. Hence it only requires the password.

Simple usage:

firebase.auth()
    .signInWithEmailAndPassword('[email protected]', 'correcthorsebatterystaple')
    .then(function(userCredential) {
        userCredential.user.updateEmail('[email protected]')
    })