<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/auth](./auth.md) &gt; [onAuthStateChanged](./auth.onauthstatechanged.md)

## onAuthStateChanged() function

Adds an observer for changes to the user's sign-in state.

<b>Signature:</b>

```typescript
export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  auth | [Auth](./auth.auth.md) | The Auth instance. |
|  nextOrObserver | [NextOrObserver](./auth.nextorobserver.md)<!-- -->&lt;[User](./auth.user.md)<!-- -->&gt; | callback triggered on change. |
|  error | ErrorFn | callback triggered on error. |
|  completed | CompleteFn | callback triggered when observer is removed. |

<b>Returns:</b>

Unsubscribe

## Remarks

To keep the old behavior, see [onIdTokenChanged()](./auth.onidtokenchanged.md)<!-- -->.

