javascriptfirebasefirebase-authentication

How to Detect User First Time Logging in Firebase on Web App Javascript


I am trying to figure out how to detect a first-time login/signup to an account in my firebase authentication. I know I can create a boolean in firebase firestore, but that is very inefficient. There is a way to do it in android and ios using AdditionalUserInfo(). Does anyone know how to do this in javascript for a web app?


Solution

  • When you call signInWithCredential() in your web app, it resolves to a UserCredential object.

    This has an additionalUserInfo property, which contains a isNewUser value.