# Is User Logged In

```javascript
// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

let isUserLoggedIn = await fm.user.isLoggedIn();
console.log(isUserLoggedIn); // false

fm.user.login().then(() => {
  isUserLoggedIn = await fm.user.isLoggedIn();
  console.log(isUserLoggedIn); // true
});
```

You may get a user's Fortmatic id and email by calling `fm.user.getUser()`

```javascript
let isUserLoggedIn = await fm.user.isLoggedIn(); // false
let userData = await fm.user.getUser(); 
// {
//   id: null
//   email: null
// }

fm.user.login().then(() => {
  userData = await fm.user.getUser(); 
  // {
  //   id: 'FORTMATIC_USER_ID'
  //   email: 'example@fortmatic.com'
  // }
});
```


---

# 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://docs.fortmatic.com/fortmatic-native/is-user-logged-in.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.
