Skip to main content

Overview

The VerifyMfaInline component provides a wrapper for embedding MFA verification within existing UI flows. It handles the transition between protected content and MFA verification, supporting both “verify first” and “verify on demand” patterns. The core features include:
  • Inline MFA verification within existing UI contexts (modals, pages, etc.)
  • Support for “verify first” mode (MFA before showing content)
  • Support for “verify on demand” mode (content first, MFA when triggered)
  • Smooth slide or fade transitions between views
  • Automatic MFA detection and handling via event-based scoping
  • Composable UI that gives developers control over layout

Architecture

The component is built using a composition pattern with a context provider that coordinates transitions between the verification view and protected content.

Composition model

The VerifyMfaInline component is composed of several subcomponents that work together:
  • VerifyMfaInline: The root wrapper component that provides context and handles MFA event listening
  • VerifyMfaInlineFlow: Manages transitions between “verify” and “content” views
  • VerifyMfaInlineBackButton: A back button for navigating from verify view to content

VerifyMfaInline

The VerifyMfaInline component wraps your protected content and automatically handles MFA verification when needed. It accepts props to control whether verification happens first or on demand. Key props:
  • verifyFirst: If true, shows MFA verification before content. If false, shows content first and triggers MFA when a protected action is called.
  • onVerified: Called when MFA verification completes successfully
  • onCancel: Called when the user cancels MFA verification
  • successDelay: Delay before transitioning to content after successful verification

VerifyMfaInlineFlow

The VerifyMfaInlineFlow component manages the display of either the MFA verification form or your protected content. It supports both simple children (used as protected content) and a render function for full control. Render function signature:
When using a render function:
  • For view === "verify": Content is the default MFA verification UI
  • For view === "content": Content is null (you provide the content)

State management (useVerifyMfaInlineContext)

The useVerifyMfaInlineContext hook provides access to the inline verification state:
  • view: Current view (“verify” or “content”)
  • goToVerify: Function to navigate to the verify view
  • goToContent: Function to navigate to the content view
  • goBack: Function to go back (handles cancellation)

Example: Verify first with ExportWallet

Show MFA verification before allowing wallet export:

Example: With back button

Add a back button outside the transition for consistent placement:

Example: Render function for full control

Use the render function to customize each view:

Example: On-demand MFA verification

Let MFA be triggered automatically when a protected action is called:

Example: Using the context hook

Access the inline MFA context for custom navigation:

API Reference

VerifyMfaInline Props

VerifyMfaInlineFlow Props

VerifyMfaInlineBackButton Props

Notes

  • Scoped MFA handling: The component uses event-based scoping to only handle MFA requests that originate from within its container. This allows multiple VerifyMfaInline instances on a page without conflicts.
  • Automatic MFA detection: When verifyFirst is false, the component listens for MFA requirements from protected actions and automatically transitions to the verify view when needed.
  • Back button visibility: The VerifyMfaInlineBackButton coordinates with the inner MFA verification flow. In verifyFirst mode, it only renders when the user has navigated within the inner MFA flow (e.g., to the method list or an alternate method). In non-verifyFirst mode, it renders on the verify view and handles both inner flow navigation and outer view transitions.
  • For enrolled users only: This component is designed for users who have already completed MFA enrollment. If MFA is not required for the user, content is shown directly without the verification step.