Can we subscribe to authentication state changes?

can we subscribe to authentication state changes ?

in the web ?

in the api ?

I want to read data from firebase on login and adjust routes accordingly

onLogin firebase(!registered) => limit to registration

onLogin && firebase(registered) => allow all except registration