How to know if a user is logging in for the first time in Firebase

To verify if a user is logging in for the first time in Firebase, we can access additionalUserInfo.isNewUser property. For example:

javascript
const logIn = async (provider) => {
    
    let user = await auth.signInWithPopup(provider);
    
    if(user.additionalUserInfo.isNewUser){
    
        // The user is logging in for the first time
        
    }
    
}

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.