Home > @firebase/auth > updatePhoneNumber
updatePhoneNumber() function
Updates the user's phone number.
Signature:
export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
user | User | The user. |
credential | PhoneAuthCredential | A credential authenticating the new phone number. |
Returns:
Promise<void>
Example
// 'recaptcha-container' is the ID of an element in the DOM.
const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
const provider = new PhoneAuthProvider(auth);
const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
// Obtain the verificationCode from the user.
const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
await updatePhoneNumber(user, phoneCredential);