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.

Summary

This hook provides a way for clients to prompt the user to authenticate with MFA via the Dynamic UI. It supports both the legacy createMfaToken flow and the recommended requestedScopes flow for elevated access tokens. The hook needs to be initialized within a child of DynamicContextProvider.

Parameters

PropertyTypeDescription
requestedScopesTokenScope[]Scopes to request an elevated access token for (recommended)
createMfaTokenboolean@deprecated — Create a single-use MFA token. Use requestedScopes instead. See migration guide.

Usage

import { usePromptMfaAuth } from '@dynamic-labs/sdk-react-core';
import { TokenScope } from '@dynamic-labs/sdk-api-core';

const App = () => {
  const promptMfaAuth = usePromptMfaAuth();

  return (
    <button
      onClick={() => promptMfaAuth({
        requestedScopes: [TokenScope.Walletexport],
      })}
    >
      Prompt MFA
    </button>
  );
};

With MFA token (deprecated)

import { usePromptMfaAuth } from '@dynamic-labs/sdk-react-core';

const App = () => {
  const promptMfaAuth = usePromptMfaAuth();

  return (
    <button
      onClick={() => promptMfaAuth({
        createMfaToken: true,
      })}
    >
      Prompt MFA
    </button>
  );
};
Last modified on June 25, 2026