The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/auth > onAuthStateChanged

onAuthStateChanged() function

Adds an observer for changes to the user's sign-in state.

Signature:

export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;

Parameters

Parameter Type Description
auth Auth The Auth instance.
nextOrObserver NextOrObserver<User> callback triggered on change.
error ErrorFn callback triggered on error.
completed CompleteFn callback triggered when observer is removed.

Returns:

Unsubscribe

Description

To keep the old behavior, see onIdTokenChanged().