Skip to main content

Recommended: JavaScript SDK with React Hooks

For new React apps, we recommend the JavaScript SDK with React Hooks (@dynamic-labs-sdk/react-hooks) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the React quickstart (JavaScript SDK) to get started.
The React SDK offers three approaches to step-up authentication, from fully managed to fully custom:
  1. promptStepUpAuth — One call that automatically picks the right verification method and shows Dynamic’s built-in UI. Recommended for most use cases.
  2. promptMfa / promptReauthenticate — Dynamic’s built-in UI with explicit control over which verification path is used.
  3. Individual verify methods — Full headless control for building your own UI.
After verification, the elevated access token is automatically stored and applied to subsequent API calls. You never need to manually handle the token. For concepts, scopes, and token lifecycle, see Step-up authentication overview.

Prerequisites

  • DynamicContextProvider configured with your environment ID
  • At least one verification method enabled in your dashboard security settings
  • Step-up authentication enabled for your environment
promptStepUpAuth checks whether the user has MFA methods and automatically routes to the correct UI — passkey/TOTP for MFA users, OTP/wallet for non-MFA users.

How promptStepUpAuth routes

Approach 2: Dynamic’s built-in UI (explicit path)

Use promptMfa or promptReauthenticate when you want to control which verification path is used while still using Dynamic’s UI:
Shows Dynamic’s MFA verification UI (passkey or TOTP). Only works when the user has registered MFA methods.

Approach 3: Headless (custom UI)

For full control over the UI, use the individual verify methods. You build the UI — the hook handles verification and token storage.

Checking if step-up is required

checkStepUpAuth is the recommended approach. It performs a server-authoritative check and returns both whether step-up is required and the available credentials, so you can route the user to the right verification method without extra API calls.
It does a fast local check first (if an elevated token exists, returns { isRequired: false } without an API call), then calls the backend. On failure, it defaults to { isRequired: true } for safety.

isStepUpRequired (simple boolean)

Use isStepUpRequired if you only need a boolean and don’t need the available credentials:
Returns true when step-up auth is enabled for the environment and no valid elevated token exists for the scope. Returns false if the token already exists or step-up is not enabled.

Email / SMS OTP

To target a specific credential, pass credentialId at call time or when initializing the hook:

Wallet signature (external wallets only)

Wallet-based step-up verification is only available for external wallets. Embedded wallets cannot be used for step-up authentication.

Passkey MFA

TOTP MFA

Social (OAuth)

The user must have the social account already linked. The SDK opens a popup to the OAuth provider — no redirect is needed. If the browser blocks the popup (e.g., on mobile), the SDK falls back to redirect and resumes the flow automatically on return.

Recovery code

Error handling

All methods update the shared state object and throw on failure:

Full example: headless credential linking

Hook reference

See the full useStepUpAuthentication reference for all return values and parameter types.

External auth (Bring Your Own Auth)

If you use external auth (BYOA), your backend can issue elevated access tokens directly using the useExternalAuth hook — no user interaction required. See the External Auth Step-Up guide.
Last modified on June 25, 2026