Optionaloptions: MfaPollingOptionsMfaPollingOptions specifying the polling interval,
success callback (onCompleted), and optional error handler (onError).
object MfaPollingResult containing:
isRunning — true while polling is active.startPolling() — starts or resumes polling.stopPolling() — stops polling immediately.mfa-push-challenge-pushreset-password-mfa-push-challenge-pushmfa-push-enrollment-qrimport { useMfaPolling } from '@auth0/auth0-acul-react/mfa-push-challenge-push';
export function MfaPushStatus() {
const { isRunning, startPolling, stopPolling } = useMfaPolling({
intervalMs: 5000,
onCompleted: () => console.log('Push approved!/denied'),
onError: (error) => console.error('Polling error:', error)
});
return (
<div>
<button onClick={startPolling} disabled={isRunning}>
{isRunning ? 'Waiting for approval…' : 'Start MFA Polling'}
</button>
{isRunning && <button onClick={stopPolling}>Cancel</button>}
</div>
);
}
onError callback receives an ULError object
with status and responseText describing the server response.429) are automatically handled:
polling waits for the reset window before retrying.startPolling() repeatedly while running is safe and idempotent.
React hook to manage MFA push polling (e.g., waiting for a push notification approval) on an Auth0 Advanced Customization of Universal Login (ACUL) screen.
This hook sets up and controls a long-running polling loop that repeatedly checks the MFA push challenge endpoint until one of the following occurs:
options.onCompleted.options.onError.stopPolling()is called, which cancels polling.Key Features
isRunningis reactive — it updates automatically if the polling loop stops internally or is canceled.useRef) to prevent duplicate network calls and unintended restarts during React re-renders.