Skip to main content

Use the @auth0/actions NPM package to write and unit test your Actions in your own code editor or IDE, with full IntelliSense, type checking, and error checking.
1

Install the package

Use one of the following package managers to install the package:
Use --save-dev while installing the package to indicate that it’s a development dependency to supplement your development tools.
2

Import the type definitions

Use one of the following alternatives to import the TypeScript definitions into your Actions depending on your technology:
Use this alternative when you want IntelliSense without changing your existing JavaScript code structure:
The import statement should be based on each trigger name and version number considering the library structure.Follow the pattern: @auth0/actions/[trigger_name]/[trigger_version]For example: @auth0/actions/post-login/v3
3

Configure your project

The following configuration examples are intentionally presented in both JavaScript and TypeScript to provide a direct, side-by-side comparison.
In your package.json, define any development dependencies to have intelliSense help when writing your Action:
4

Write your Action code

The following example Action would execute during the Post-Login flow. It checks if the user has roles assigned, and calls api.access.deny() if none are found. If roles are present, it proceeds to set the custom claim on the ID token.The import statement declares the availability of external types to your code. This allows the editor to know the structure of the event and api objects.
CheckpointYou should now have a working Action, written and type-checked in your own code editor, ready to be deployed to Auth0.