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.
install-npm.sh
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:
jsdocs-import.js
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
@auth0/actions
credentials-exchange
v1
v2
custom-email-provider
v1
custom-phone-provider
v1
custom-token-exchange
v1
event-stream
v1
password-reset-post-challenge
v1
post-change-password
v1
v2
post-login
v1
v2
v3
post-user-registration
v1
v2
pre-user-registration
v1
v2
send-phone-message
v1
v2
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:
package.json
In your jsconfig.json, define any development dependencies to have intelliSense help when writing your Action.
jsconfig.json
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.
example.js
CheckpointYou should now have a working Action, written and type-checked in your own code editor, ready to be deployed to Auth0.