# Get the logged in user

At any time, you can use the `currentUser` property to get the signed in user.

```javascript
const currentUser = adamite().auth().currentUser;
const userId = currentUser.id;
```

You can also subscribe to changes to the auth state using the `onAuthStateChange` method.

```javascript
adamite().auth().onAuthStateChange(currentUser => {
  if (currentUser) {
    console.log("logged in as " + currentUser.id);
  } else {
    console.log("not logged in");
  }
});
```

The `onAuthStateChange` method returns a function that can be called to unsubscribe from auth state changes.

```javascript
const unsubscribe = adamite().auth().onAuthStateChange(currentUser => {
  // ...
});

unsubscribe();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://adamite.gitbook.io/docs/sdk/authentication/get-the-logged-in-user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
