where to place firebase.auth().onAuthStateChanged() in Vuejs

Viewed 4699

I need to check whether the user logged in with Firebase. For this we use

        firebase.auth().onAuthStateChanged(function(user){
       // example
       this.user = user
       })

We are also using Vue.js so I was wondering whether it should be implemented as a watcher, method or even a computed property. And of course how that would be implemented.

2 Answers

In the created () method of the main.js file

Related