# anonymize

Learn how to anonymize users on the server side.

This function dissociates the current session from an identified user. It is the server-side equivalent of the client-side [`anonymize`](/reference/sdk/javascript/api/plug/anonymize) method.

Call this function when a user logs out of your application to clear their identity. The SDK issues a new anonymous token and updates the corresponding cookie.

## Signature

This function has the following signature:

```ts
function anonymize(): Promise<void>
```

## Example

Here is an example of how to use this function in a server API route:

**Anonymize example**

**JavaScript**

```js
export default defineEventHandler(async () => {
  // Your logic to log out the user

  await anonymize();

  return {success: true};
})
```

**TypeScript**

```ts
export default defineEventHandler(async () => {
  // Your logic to log out the user

  await anonymize();

  return {success: true};
})
```
