Skip to main content

Concepts

How Auth0 Actions Work

Describes how Auth0 Actions work and what you can accomplish with them.

About Actions Templates

The Actions Template gallery offers our customers a wide variety of starter templates on their way to creating an action

About Actions Modules

Create reusable, Auth0-hosted code with its own secrets and NPM dependencies to share functions across multiple Actions bound to different triggers.

About the Official Actions NPM Package

The Actions NPM (@auth0/actions) package enables the use of TypeScript development on external projects, allowing developers to follow best practices and improve their unit testing based on the TypeScript definitions.

Coding Guidelines for Actions

Write clear, concise, and secure Actions code with our coding guidelines.

About Handling Scopes in Actions

Modify token scopes with Post Login and Credentials Exchange Actions while respecting authorization policies.

Actions Limitations

Review the constraints that apply to Auth0 Actions and Auth0 Modules so you can design custom code that stays within enforced limits.

How To

Write Your First Action

Learn how to write an Action, which includes choosing a flow, creating an Action and configuring it, and binding it to the flow.

How to Write Actions Using Your Code Editor

Install the official @auth0/actions NPM package as a dev dependency to add TypeScript type definitions, IntelliSense, and error checking when writing and unit testing Auth0 Actions by trigger and version in external editors.

How to Write Your First Action Module

Build your first Auth0 Action Module in the Auth0 Dashboard by creating the module, adding secrets and NPM dependencies, publishing a version, and using it to send logs to an external service.

How to Share Data Across Actions using Actions Transaction Metadata

Pass user or application metadata between login and post-login Actions by using Actions Transaction Metadata.

How to Redirect Users During Authentication with Actions

Use post-login Actions to redirect users before an authentication transaction is complete.

How to Manage NPM Package Dependencies in Actions

Add npm registry packages as dependencies to Auth0 Actions using the Actions Code Editor in the Auth0 Dashboard or the Management API and review security guidance and native and private module limitations.

How to Manage Action Versions

Compare between drafted and deployed versions of Actions or revert to previous versions using the Actions versions history.

How to Test Actions

Test and debug Auth0 Actions by running sample payloads in the Actions Code Editor or Management API, verifying end-to-end flows with tenant logs, and completing unit tests for your handler code with mocked event and API objects.

How to View Actions Real-Time Logs in the Auth0 Dashboard

Use the Actions Real-time Logs panel in the Auth0 Dashboard to stream live console output and exceptions from Actions, Custom Database Scripts, and Custom Social Connections to debug your custom code as it executes.

Write Unit Tests

Unit Test an Action

Unit tests for a Post Login action that sets a user’s roles as a custom ID token claim, denying access when no roles are present, using Jest, Mocha, and Node.js Test Runner in JavaScript and TypeScript.

Unit Test an Action That Uses a Module

Unit tests for a Post Login action that fetches user roles from an external service through a custom module and sets them as an access token claim, denying access on failure, using Jest, Mocha, and Node.js Test Runner in JavaScript and TypeScript.

Unit Test an Action's Dependencies

Unit tests for a Pre User Registration action that blocks a forbidden email domain and validates a submitted full name before storing it and a generated identifier in user and app metadata, using Jest, Mocha, and Node.js Test Runner in JavaScript and TypeScript.

Unit Test an Action That Renders a Form

Unit tests for a Post Login action that renders a marketing consent Form and stores the submitted answer, denying access when no answer is submitted, using Jest, Mocha, and Node.js Test Runner in JavaScript and TypeScript.

Unit Test an Action That Redirects the User

Unit tests for a Password Reset Post Challenge action that redirects high-risk users for identity verification and validates the returned token before continuing, using Jest, Mocha, and Node.js Test Runner in JavaScript and TypeScript.

Migrate to Actions

How to Migrate from Rules to Actions

Migrate your existing Auth0 Rules code to Auth0 Actions code.

How to Use Rule Migration Tooling

Description on how to use the Rule migration tooling in the Auth0 dashboard

How to Migrate from Hooks to Actions

Migrate your existing Auth0 Hooks code to Auth0 Actions code.

Reference

Available Triggers

Triggers are events that automatically invoke an Action when a specific operation, such as a user logging in, occurs at runtime.

Use Cases

Action Use Cases

Browse a curated index of example Auth0 Actions implementations to quickstart your own custom logic.