google auth.onstatechange

JavaScript
firebase.auth().onAuthStateChanged(function(user) {  if (user) { 
// User is signed in. 
} 
  else {   
    // No user is signed in.
  }});
Source

Also in JavaScript: