> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from Node 16 to Node 22

> Learn the steps and considerations for moving Actions, Custom Database scripts, Custom Social Connection scripts, Rules, and Hooks from the Node 16 extensibility runtime to Node 22.

Node 16 is deprecated and the Node.js project no longer provides security fixes for it.

After the Node 16 runtime is removed from your tenant, extensibility that still targets it is forced to run on the latest available runtime.

Moving directly from Node 16 to Node 22 skips Node 18, so you take on its changes together with Node 22's.

Upgrade as soon as possible to follow code security best practices.

## Considerations

### Differences between Node 16 and Node 22

| Area | Node 16 | Node 22 | What to do |
| - | - | - | - |
| npm modules | Versions listed for older runtimes. | Only versions listed for Node 22. | Check each module in [Can I require: Auth0 Extensibility](https://auth0-extensions.github.io/canirequire/). Hooks and Actions add the module as a dependency. |
| Removed module versions | Some module versions are available. | Node 18 removed support for some of them. | If your Rules, Custom Database scripts, or Custom Social Connection scripts depend on an older version, update it. To see the versions, read [Can I Require](https://auth0.com/docs/customize/extensibility-runtime/npm-modules/can-i-require.md#module-versions-removed-in-node-18). |
| `use npm` directive | Available. | Not available. | Add dependencies explicitly. |
| Filesystem write access | Available. | Disabled. | Remove code that writes to the filesystem. |
| Module-level code in Actions | Not applicable. | Runs once per instance of your Action and may be reused across many executions. | Don't keep per-request state at module level. |
| [Magic globals](https://auth0.com/docs/customize/extensibility-runtime/npm-modules/magic-globals.md) | Unavailable. | Unavailable. | No additional change. |
| ECMAScript support | ES2021. | ES2024, including `Object.groupBy` and `Promise.withResolvers`. | Optional: use the new language features. |
| Global `fetch`, `structuredClone`, and Web Crypto `crypto` | Not available. | Available. | Optional: if your code uses a `fetch` or `crypto` replacement from a module, you can keep it or switch to the global. |
| TLS | Legacy (unsafe) renegotiation allowed. | Secure renegotiation (RFC 5746) is required by default, because the underlying OpenSSL requires it. If your code makes external network calls, the target servers must support it, or requests fail with an `unsafe legacy renegotiation disabled` error. | Test connections to external services and update the target servers to support secure renegotiation. See [Support secure renegotiation for TLS](#support-secure-renegotiation-for-tls). |
| Action Modules | Not applicable. | APIs deprecated in Node.js 22 fail. | Update deprecated APIs. |
| Custom Social Connections | Scripts run on the tenant-wide runtime. | Scripts run on Node 22 when you change the tenant-wide runtime. | Find them with the [GET all connections](https://auth0.com/docs/api/management/v2/connections/get-connections.md) endpoint, filtering by `strategy=oauth1&strategy=oauth2`. This includes connections added through the Marketplace. The Auth0 Dashboard (Auth0 Dashboard: Auth0's main product to configure your services.) doesn't allow updating scripts for Marketplace connections, so use the [Management API](https://auth0.com/docs/api/management/v2.md) if a script needs changes. |

> [!WARNING]
>
> Module-level code in your Actions is invoked once per instance of your Action and may be reused across many executions.

> [!WARNING]
>
> The fetch user profile script for the [Indeed](https://marketplace.auth0.com/integrations/indeed-social-connection), [monday.com](https://marketplace.auth0.com/integrations/monday-com-monday-com-social-connection), [Snapchat](https://marketplace.auth0.com/integrations/snapchat-social-connection), and [Tumblr](https://marketplace.auth0.com/integrations/tumblr-social-connection) Marketplace connections used version `0.22.0` of `axios`, which isn't available in Node 18 or later. If you use one of them, review and update its script through the Management API.

## Migration steps

### Assess resources

List the Actions, Custom Database scripts, Custom Social Connection scripts, Rules, and Hooks that run on Node 16.

### Upgrade code

Address the changes in the table above.

### Support secure renegotiation for TLS

If requests to external services fail with an error similar to the following, the target server doesn't support secure renegotiation:

```text wrap lines theme={null}
Error: write EPROTO C0BAF076:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:
```

Update the target servers to support secure renegotiation. If the servers are third-party servers you don't control, you can opt in to the legacy behavior per request, but this reduces security. For example, with `axios`:

```javascript wrap lines theme={null}
const axios = require('axios');
const https = require('https');
const crypto = require('crypto');

axios.get(
  'https://YOUR_LEGACY_SERVER',
  {
    httpsAgent: new https.Agent(
      {
        secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT
      }
    )
  })
```

### Upgrade existing Actions

Upgrade each Action individually by [creating and deploying a new version](https://auth0.com/docs/customize/actions/manage-versions.md) with **Node 22 (Recommended)** as the runtime.

You can [revert](https://auth0.com/docs/customize/actions/manage-versions.md#revert-actions) to the previous version on the older runtime.

### Change the tenant-wide runtime

Custom Database scripts and Custom Social Connection scripts use the tenant **Extensibility** runtime. Rules and Hooks use the same runtime unless you set a **Legacy Extensibility** override, so when no override is set, changing the Extensibility runtime changes all of them at the same time. Test in a development tenant first, then promote to production only when you see no issues.

1. Navigate to **Auth0 Dashboard > Settings > Advanced**.
2. Scroll to the **Extensibility** section.
3. For **Runtime**, select **Node 22**.
4. Under **Legacy Extensibility**, check **Runtime**. If it's set to an older version, select **Node 22** or **Same as current runtime**.
5. Save your changes.

### Upgrade Extensions

[Extensions](https://auth0.com/docs/customize/extensions/overview.md) have their own Node.js runtime version, which is determined when you install or upgrade each one. Changing the tenant-wide runtime doesn't change the runtime of your Extensions, so upgrade each Extension separately to run it on the latest runtime.

To learn more, read [Configure the Runtime](https://auth0.com/docs/customize/extensibility-runtime/configure-runtime.md), [Node 22](https://auth0.com/docs/customize/extensibility-runtime/runtimes/node-22.md), and [Best Practices](https://auth0.com/docs/customize/extensibility-runtime/best-practices.md).
