@auth0/auth0-acul-js

中文文档
1.11.0发布于 2026/11/05MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 79.6万

The Auth0 ACUL JS SDK enables you to work with Advanced Customization for Universal Login.

原始使用文档
文档目录20 节
  1. 📚 Documentation
  2. 🚀 Getting started
  3. Prerequisites
  4. Installation
  5. Importing Screens
  6. 👨‍💻 Usage
  7. Adding Functionality to Your Screens
  8. Quick Start with Boilerplate App
  9. 💻 API reference
  10. Screens
  11. Helper Functions
  12. Context properties
  13. Identifier management
  14. Form validation
  15. MFA / Push polling & resend
  16. Common helpers
  17. 💬 Feedback
  18. Contributing
  19. Raise an issue
  20. Vulnerability Reporting

Auth0 ACUL JS SDK

ACUL JS SDK

NPM Version Downloads codecov License

The Auth0 ACUL JS SDK enables you to work with Advanced Customization for Universal Login.

It simplifies integrating authentication screens (login, signup, passwordless, passkey enrollment, etc.) into your web applications, providing the necessary tools for seamless implementation.

📚 Documentation

  • Quickstart - our guide for setting up the SDK on your app.
  • Guides - more guides for common use cases
  • Examples - code snippets for different customization use cases.
  • FAQs - Find answers to frequently asked questions about the Auth0 ACUL JS SDK.

🚀 Getting started

Prerequisites

Before starting, ensure that you have the following setup:

  1. Custom Domain: Ensure that a custom domain is configured for your Auth0 tenant.
  2. Screen Configuration: Set up the required authentication screens within your Auth0 flow.
    For detailed steps, refer to the Configure ACUL Screens.

Installation

You can easily install the SDK via npm:

npm install @auth0/auth0-acul-js

After installing the SDK, you can import the relevant screen module, which you want to configure

Importing Screens

// Default import of any particular screen, eg: login-id screen
import  LoginId  from '@auth0/auth0-acul-js/login-id'; 

// Named import of any screen
import  { LoginId }  from '@auth0/auth0-acul-js'; 

// Default import of all screens
import  * as Screens  from '@auth0/auth0-acul-js'; 

Note: For more details on import paths for all screens, refer to the FAQ's.

👨‍💻 Usage

Adding Functionality to Your Screens

Let’s look at an example for adding logic to the login-id screen.

Example: Add Logic to Login Button

  import  LoginId  from '@auth0/auth0-acul-js/login-id';

  const loginIdManager = new LoginId();

  // Trigger the login method on button click
  loginIdManager.login({
    username: "testUser"
  });

Get List of Mandatory Fields for Login

const { transaction } = loginIdManager
const requiredFields = transaction.getActiveIdentifiers();

Integrating Social Connections for Login

To allow users to login via social connections (e.g., Google, Facebook), use the following snippet

import  LoginId  from "@auth0/auth0-acul-js/login-id";
const loginIdManager = new LoginId();

// Check if alternateConnections is available and has at least one item
if (!loginIdManager.transaction.alternateConnections) {
  console.error('No alternate connections available.');
}

// Select the first available connection (users can select any available connection)
const selectedConnection = alternateConnections[0];

// Log the chosen connection for debugging or informational purposes
console.log(`Selected connection: ${selectedConnection.name}`);

// Proceed with social login using the selected connection
loginIdManager.socialLogin({
  connection: selectedConnection.name,
})

Error handling for Login

A top-level getter function, getErrors, can be used to retrieve detailed authentication errors when backend validation fails.

import Login from "@auth0/auth0-acul-js/login";

const loginIdManager = new Login();

const errors = loginIdManager.getErrors();
if (errors) {
  console.error("Login failed:", errors);
}

Same can also be achieved using the transaction.errors available directly on the screen context for each screen.

import Login from "@auth0/auth0-acul-js/login";

const loginIdManager = new Login();

const errors = loginIdManager.transaction?.errors ?? [];
if (errors) {
  console.error("Login failed:", errors);
}

For more examples, visit our examples

Quick Start with Boilerplate App

Get up and running quickly with our boilerplate starter template: Link

💻 API reference

Screens

No.PromptScreen NameDocumentation Link
1loginloginLink
2login-idlogin-idLink
3login-passwordlogin-passwordLink
4signup-idsignup-idLink
5signup-passwordsignup-passwordLink
Explore more Screens...
No.PromptScreen NameDocumentation Link
6login-passwordlesslogin-passwordless-email-codeLink
7login-passwordlesslogin-passwordless-sms-otpLink
8passkeyspasskey-enrollmentLink
9passkeyspasskey-enrollment-localLink
10phone-identifier-enrollmentphone-identifier-enrollmentLink
11phone-identifier-challengephone-identifier-challengeLink
12email-identifier-challengeemail-identifier-challengeLink
13captchainterstitial-captchaLink
14reset-passwordreset-password-emailLink
15reset-passwordreset-password-requestLink
16reset-passwordreset-passwordLink
17reset-passwordreset-password-errorLink
18reset-passwordreset-password-successLink
19signupsignupLink
20mfamfa-detect-browser-capabilitiesLink
21mfamfa-enroll-resultLink
22mfamfa-begin-enroll-optionsLink
23mfamfa-login-optionsLink
24mfa-pushmfa-push-enrollment-qrLink
25mfa-pushmfa-push-welcomeLink
26mfa-pushmfa-push-challenge-pushLink
27mfa-pushmfa-push-listLink
28mfa-smsmfa-country-codesLink
29mfa-smsmfa-sms-challengeLink
30mfa-smsmfa-sms-enrollmentLink
31mfa-smsmfa-sms-listLink
32mfa-emailmfa-email-challengeLink
33mfa-emailmfa-email-listLink
34invitatinoaccept-invitationLink
35organizationsorganization-pickerLink
36organizationsorganization-selectionLink
37reset-passwordmfa-otp-challengeLink
38mfa-otpmfa-otp-enrollment-codeLink
39mfa-otpmfa-otp-enrollment-qrLink
40reset-passwordreset-password-mfa-email-challengeLink
41reset-passwordreset-password-mfa-push-challenge-pushLink
42reset-passwordmfa-sms-challengeLink
43reset-passwordreset-password-mfa-otp-challengeLink
44mfa-phonemfa-phone-enrollmentLink
45mfa-voicemfa-voice-enrollmentLink
46mfa-recovery-codemfa-recovery-code-challengeLink
47device-flowdevice-code-activation-allowedLink
48device-flowdevice-code-activation-deniedLink
49device-flowdevice-code-activationLink
50reset-passwordreset-password-mfa-recovery-code-challengeLink
51reset-passwordreset-password-mfa-voiceLink
52commonredeem-ticketLink
53device-flowdevice-code-confirmationLink
54mfa-phonemfa-phone-challengeLink
55mfa-voicemfa-voice-challengeLink
56mfa-recovery-codemfa-recovery-code-enrollmentLink
57reset-passwordreset-password-mfa-phone-challengeLink
58mfa-recovery-codemfa-recovery-code-challenge-new-codeLink
59logoutlogoutLink
60logoutlogout-abortedLink
61logoutlogout-completeLink
62email-verificationemail-verification-resultLink
63login-email-verificationlogin-email-verificationLink
64mfa-webauthnmfa-webauthn-platform-enrollmentLink
65mfa-webauthnmfa-webauthn-errorLink
66mfa-webauthnmfa-webauthn-roaming-enrollmentLink
67mfa-webauthnmfa-webauthn-roaming-challengeLink
68mfa-webauthnmfa-webauthn-platform-challengeLink
69mfa-webauthnmfa-webauthn-enrollment-successLink
70mfa-webauthnmfa-webauthn-change-key-nicknameLink
71mfa-webauthnmfa-webauthn-not-available-errorLink
72reset-passwordreset-password-mfa-webauthn-platform-challengeLink
73reset-passwordreset-password-mfa-webauthn-roaming-challengeLink
74consentconsentLink
75customized-consentcustomized-consentLink
76email-otp-challengeemail-otp-challengeLink
77confirmationconfirmationLink
78consentpending-consentLink

Helper Functions

This section documents the helper methods and properties exposed by the screen instance in auth0-acul-js.

Context properties

  • user- Current user/profile data for the active transaction.

  • tenant- Tenant configuration and metadata (domain, region, settings).

  • branding- Branding/theme config (colors, logos, fonts, visual tokens). branding.themes.default.identifiers additionally carries identifier display preferences (loginDisplay, otpAutocomplete, phoneDisplay with masking and formatting); the identifiers key is omitted when the tenant configures none of them.

  • client- Application client metadata and settings.

  • countryCodes- Available phone country codes (available, each with code, label, dialCode) and the recommended default (recommended); null when not provided. On the signup and login screens, pass the selected code back as phoneCountryCode alongside the phone number to submit both from one screen instead of routing through pickCountryCode(). On login and login-id it is required with identifierType: 'phone'.

  • organization- Organization context when applicable.

  • prompt- Current prompt / flow configuration.

  • untrustedData- Untrusted inputs (URL params, prefilled form values).

  • screen- Current screen metadata and configuration.

  • transaction- Transaction / flow state, session identifiers and related data.

  • experiment- Active Experiment Center experiment for the current screen, or null when no experiment is active or the screen has not opted in via context_configuration. Exposes the assigned variation (experimentId, variationId, variationName, variationDescription, isControl) and the resolved config (an experiment-defined map — read a key's resolved value via its value property, e.g. experiment.config?.['show_passkey']?.value, and always null-check experiment first (config may be absent, so guard it with ?. too)). Branch on isControl to render baseline vs. treatment UI.

Identifier management

  • getLoginIdentifiers(): Get available login identifier types (email, phone, username)

  • getSignupIdentifiers(): Get available signup identifier types, each with its required status

Form validation

  • validatePassword(password: string): Real-time password strength validation
  • validateUsername(username: string): Username format and availability validation

MFA / Push polling & resend

  • pollingManager(): Starts and manages polling for an MFA push challenge.

  • resendManager() Gets resend functionality with timeout management for this screen.

Common helpers

  • getCurrentScreen()
    Return the current screen context data.

  • getCurrentThemeOptions() Gets the current theme options with flattened configuration from branding context. Returns styling tokens only (colors, fonts, borders, pageBackground, widget) — read branding.themes.default.identifiers for identifier display preferences.

  • getErrors() Gets the current errors from the transaction context

💬 Feedback

Contributing

We appreciate feedback and contribution to this repo! Before you get started, please see the following:

Raise an issue

To provide feedback or report a bug, please raise an issue on our issue tracker.

Vulnerability Reporting

Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.


Auth0 Logo

Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?

This project is licensed under the MIT license. See the LICENSE file for more info.

版本与发布记录

@auth0/auth0-acul-js 共发布 30 个版本,首次发布于 2024/12/06;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.11.0latest2026/11/052 天前
1.10.02026/10/2315 天前
1.9.02026/09/241 个月前
1.8.02026/09/161 个月前
1.7.02026/08/252 个月前
1.6.02026/07/163 个月前

其他发布通道:beta → 0.1.0-beta.9,alpha → 1.0.0-alpha.4。

关于 @auth0/auth0-acul-js 的常见问题

@auth0/auth0-acul-js 是什么?

The Auth0 ACUL JS SDK enables you to work with Advanced Customization for Universal Login.

如何安装 @auth0/auth0-acul-js?

在项目目录运行 npm install @auth0/auth0-acul-js,或使用 pnpm add / yarn add / bun add。

@auth0/auth0-acul-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@auth0/auth0-acul-js 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@auth0/auth0-acul-js 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@auth0/auth0-acul-js 可以商用吗?

@auth0/auth0-acul-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@auth0/auth0-acul-js 的下载量有多少?

根据 npm 官方下载统计,@auth0/auth0-acul-js 在 2026/10/07 – 2026/11/05 这 30 天内被下载 795,901 次,日均约 26,530 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@auth0/auth0-acul-js 还在维护吗?

最新版本 1.11.0 发布于 2026/11/05(2 天前);至今共发布 30 个版本,其中过去 12 个月发布了 14 个;首次发布于 2024/12/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。