# isAnonymous

Learn how to check whether the user is anonymous.

This method checks whether the current session is anonymous.

A user is anonymous if they have no identifier. Consequently, a token without a subject is also considered anonymous.

> **Best practice**
>
> For better readability, use the [`isIdentified`](is-identified) method instead of a negation when checking if the user is identified.

## Signature

This method has the following signature:

```ts
user.isAnonymous(): boolean
```

This method returns `true` if the user is anonymous, `false` otherwise.

## Example

Here is a basic example of how to use this method:

```ts
import croct from '@croct/plug';

if (croct.user.isAnonymous()) {
  console.log('The user is anonymous');
} else {
  console.log('The user is identified');
}
```
