# Does the Auth0 ManagementClient (from the auth0 npm package) automatically renew tokens if used as a singleton?

**URL:** <https://community.auth0.com/t/does-the-auth0-managementclient-from-the-auth0-npm-package-automatically-renew-tokens-if-used-as-a-singleton/185391>\
**Category:** Get Help\
**Tags:** clients, management-api\
**Created:** [April 11, 2025, 9:25pm UTC](https://community.auth0.com/t/does-the-auth0-managementclient-from-the-auth0-npm-package-automatically-renew-tokens-if-used-as-a-singleton/185391 "2025-04-11T21:25:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IlyaMarvinIlyashyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ilyamarvinilyashyk/32/74230_2.png) [@IlyaMarvinIlyashyk](https://community.auth0.com/u/IlyaMarvinIlyashyk)\
**Post date:** [April 11, 2025, 9:25pm UTC](https://community.auth0.com/t/does-the-auth0-managementclient-from-the-auth0-npm-package-automatically-renew-tokens-if-used-as-a-singleton/185391/1 "2025-04-11T21:25:48Z")

</div>

I’m currently using the Auth0 `ManagementClient` from the `auth0` npm package in my Next.js app in a singleton pattern like this:

```auto
import { ManagementClient } from 'auth0';

let managementClient: ManagementClient | null = null;

const getManagementClient = () => {
  if (!managementClient) {
    managementClient = new ManagementClient({
      domain: process.env.AUTH0_MANAGEMENT_API_DOMAIN,
      clientId: process.env.AUTH0_CLIENT_ID,
      clientSecret: process.env.AUTH0_CLIENT_SECRET,
    });
  }
  return managementClient;
};

```

My question is:

Does the `ManagementClient` automatically handle access token renewal after the token expires (e.g., after the default 24 hours)? Or do I need to handle the token renewal manually if I’m using a singleton like this?

If manual renewal is needed, what’s the recommended best practice for this?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [April 11, 2025, 11:22pm UTC](https://community.auth0.com/t/does-the-auth0-managementclient-from-the-auth0-npm-package-automatically-renew-tokens-if-used-as-a-singleton/185391/3 "2025-04-11T23:22:56Z")

</div>

Hi @IlyaMarvinIlyashyk

Welcome to the Auth0 Community!

The management client should automatically handle the access token renewal as long as it is initiated correctly within your application.

Alternatively, the management client can be initialized this way as well:

```auto
import { ManagementClient } from 'auth0';

var management = new ManagementClient({
  domain: '{YOUR_TENANT_AND REGION}.auth0.com',
  token: '{YOUR_API_V2_TOKEN}',
});

```

If you have any other questions, please let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 25, 2025, 11:23pm UTC](https://community.auth0.com/t/does-the-auth0-managementclient-from-the-auth0-npm-package-automatically-renew-tokens-if-used-as-a-singleton/185391/4 "2025-04-25T23:23:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
