hey,
i’m trying to display the current user but it shows me null.
this is my code
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.rootPage = HomePage;
console.log(“I’m here! HomePage”);
} else {
this.rootPage = LoginPage;
console.log(“I’m here! LoginPage”);
}
});
after login it goes to HomePage and it working good.
then i wrote
this.currentUser = firebase.auth().currentUser;
console.log(this.currentUser);`
it print me null.
Any news on this?
I’m facing the same issue and get crazy about it.
trying console.log(firebase.auth())
shows me the whole object but console.log(firebase.auth().currentUser)
is null
Found it myself 
during initialization firebase.auth().currentUser is null so you should use
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
} else {
// No user is signed in.
}
});
as recommended here https://firebase.google.com/docs/auth/web/manage-users
1 Like