Overview
TheVerifyMfaInline 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
TheVerifyMfaInline component is composed of several subcomponents that work together:
VerifyMfaInline: The root wrapper component that provides context and handles MFA event listeningVerifyMfaInlineFlow: Manages transitions between “verify” and “content” viewsVerifyMfaInlineBackButton: A back button for navigating from verify view to content
VerifyMfaInline
TheVerifyMfaInline 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: Iftrue, shows MFA verification before content. Iffalse, shows content first and triggers MFA when a protected action is called.onVerified: Called when MFA verification completes successfullyonCancel: Called when the user cancels MFA verificationsuccessDelay: Delay before transitioning to content after successful verification
VerifyMfaInlineFlow
TheVerifyMfaInlineFlow 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:
- For
view === "verify":Contentis the default MFA verification UI - For
view === "content":Contentisnull(you provide the content)
State management (useVerifyMfaInlineContext)
TheuseVerifyMfaInlineContext hook provides access to the inline verification state:
view: Current view (“verify” or “content”)goToVerify: Function to navigate to the verify viewgoToContent: Function to navigate to the content viewgoBack: 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
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | required | Should include VerifyMfaInlineFlow and optionally VerifyMfaInlineBackButton |
verifyFirst | boolean | true | If true, shows MFA verification before content |
onVerified | () => void | - | Called when MFA verification completes |
onCancel | () => void | - | Called when MFA verification is cancelled |
successDelay | number | 500 | Delay (ms) before transitioning to content after success |
className | string | - | Additional CSS classes |
VerifyMfaInlineFlow Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((props) => ReactNode) | required | Protected content or render function |
className | string | - | Additional CSS classes |
animateHeight | boolean | true | Whether to animate height during transitions |
autoFocus | boolean | true | Whether to auto-focus forms |
transition | "slide" | "fade" | "slide" | Transition animation type |
VerifyMfaInlineBackButton Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | ButtonSize | "md" | Button size |
variant | ButtonVariant | "transparentSecondary" | Button variant |
Notes
- Scoped MFA handling: The component uses event-based scoping to only handle MFA requests that originate from within its container. This allows multiple
VerifyMfaInlineinstances on a page without conflicts. - Automatic MFA detection: When
verifyFirstisfalse, the component listens for MFA requirements from protected actions and automatically transitions to the verify view when needed. - Back button visibility: The
VerifyMfaInlineBackButtononly renders when there’s somewhere to go back to (i.e., not inverifyFirstmode when on the verify view). - 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.