> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# npm Modules

> Learn how to use npm modules in the extensibility runtime, including Can I require, the npm public registry, and magic globals.

The extensibility runtime is a sandbox, so how you get an npm module depends on the extensibility type. Some types install modules from the [npm public registry](https://www.npmjs.com/). Others can only `require` modules that Auth0 provides, which you check with [Can I require: Auth0 Extensibility](https://auth0-extensions.github.io/canirequire/). Older runtimes also expose some modules as magic globals.

| Extensibility type | How you get modules |
| - | - |
| Actions | Install from the npm public registry. |
| Custom Database scripts | Use a module listed in Can I require. |
| Custom Social Connection scripts | Use a module listed in Can I require. |
| Hooks | Install from the npm public registry. |
| Rules | Use a module listed in Can I require. |

## npm public registry

Actions and Hooks let you add a module and version as a dependency, and Auth0 installs it from the [npm public registry](https://www.npmjs.com/). You don't need Can I require.

* Add the module and version as a dependency of the Action or Hook, then `require` it in your code.
* Modules must be public. Modules from private repositories aren't supported.
* Modules that rely on [native add-ons](https://www.npmjs.com/package/node-gyp) can't be installed.
* Make sure the version you pick supports the Node.js runtime you selected.

To learn more, read [Write Your First Action](https://docs-dev.mintlify.site/docs/customize/actions/write-your-first-action.md).

## Can I require

Rules, Custom Database scripts, and Custom Social Connection scripts can't install modules. They can only `require` the modules and versions that Auth0 provides in the sandbox, and that list differs for each runtime. To check a module, find alternatives, and see the versions Node 18 removed, read [Can I Require](https://docs-dev.mintlify.site/docs/customize/extensibility-runtime/npm-modules/can-i-require.md).

## Magic globals

On Node 12, Rules and Custom Database scripts expose some npm modules as globals, such as `_`, `async`, `jwt`, and `request`, so you can use them without calling `require`. These are called magic modules or magic globals.

| Runtime | Magic globals |
| - | - |
| Node 26 | Removed. Explicitly `require` them. |
| Node 22 | Removed. Explicitly `require` them. |
| Node 18 | Removed. Explicitly `require` them. |
| Node 16 | Removed. Explicitly `require` them. |
| Node 12 | Available without `require`. |

To see the full list of globals and how to replace them, read [Magic Globals](https://docs-dev.mintlify.site/docs/customize/extensibility-runtime/npm-modules/magic-globals.md).

## When you change runtimes

Module availability can change between runtimes, and some modules or versions are removed.

* For Actions and Hooks, confirm that each dependency supports the target runtime.
* For Rules, Custom Database scripts, and Custom Social Connection scripts, check every `require`d module against the target runtime in Can I require, and replace any magic globals.

To learn more, read:

* [Configure the Runtime](https://docs-dev.mintlify.site/docs/customize/extensibility-runtime/configure-runtime.md)
* [Migrate from Node 18 to Node 22](https://docs-dev.mintlify.site/docs/customize/extensibility-runtime/migrate/from-node-18-to-node-22.md)
* [Best Practices](https://docs-dev.mintlify.site/docs/customize/extensibility-runtime/best-practices.md)
