[Vuejs]-Is there a way to dynamically assign a country to defaultCountry in firebase phone authentication for web?

0👍

If this.getDefaultCountry() is synchronous (i.e. doesn’t require any database lookups, promises, etc), you should be able to use the following code, where defaultCountry is swapped out for a getter instead of a static value:

signInOptions: [
  firebase.auth.EmailAuthProvider.PROVIDER_ID,
  {
    provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
    recaptchaParameters: {
        type: 'image',
        size: 'invisible',
        badge: 'bottomleft'
    },
    get defaultCountry() {
      // contents of getDefaultCountry here
    }
  }
]

If your this.getDefaultCountry() is asynchronous, you will instead have to show some form of loading screen while you get the value, build signInOptions, give it to your FirebaseUI config and then finally render it.

Leave a comment