React hook that enables browser Conditional UI (passkey autofill) functionality for login
identifier fields on Auth0 Advanced Customization of Universal Login (ACUL) screens.This hook initializes the browser’s Conditional Mediation API, which surfaces stored
device passkeys in the username field’s autocomplete dropdown without requiring
additional user interaction.
- The hook registers once per page lifecycle — calling it multiple times is safe.
- Gracefully degrades on unsupported browsers without blocking user interaction.
- Binding the returned
inputRefto an input element ensures the correctautocomplete="username webauthn"attribute is applied automatically. - If your input already declares
autocomplete="username webauthn"in markup, binding the ref is optional — the hook still registers correctly.
Key Features
- Automatic Conditional Mediation — initializes passkey autofill without any manual browser API calls.
- Ref-optional design — works with or without binding
inputRefto the input element. - Zero-friction fallback — unsupported environments are handled silently, preserving normal login flow.
Parameters
None.Returns
UsePasskeyAutofillResultObject containing:inputRef(optional) — a React ref to attach to the username input element. Ensures the correctautocompleteattribute is set when bound.
Supported Screens
login-id
Example
Remarks
- If
inputRefis not bound to an input, ensure the input element explicitly declaresautocomplete="username webauthn"so the browser can associate it with passkey autofill. - The hook has no effect in environments where the Conditional Mediation API is unavailable (e.g. older browsers or non-HTTPS contexts) — no errors are thrown.
- Call
usePasskeyAutofillonce at the top level of your component; do not call it conditionally or inside event handlers.