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.
If you use Bring Your Own Auth (BYOA), you can issue elevated access tokens directly from your backend without prompting the user for re-authentication or MFA. The useExternalAuth hook provides verifyWithExternalJwt to exchange your backend’s assertion JWT for an elevated access token. This is useful when your backend has already verified the user’s identity through its own means (e.g., a session, an internal auth check, or a custom challenge) and you want to authorize a sensitive Dynamic operation without additional user friction. For concepts, scopes, and token lifecycle, see Step-up authentication overview.

Prerequisites

  • DynamicContextProvider configured with your environment ID
  • External auth (BYOA) configured with a JWKS URL in your dashboard
  • The user is already signed in via external auth

How it works

  1. Your backend creates an assertion JWT signed with the same key registered in your environment’s JWKS URL.
  2. The verifyWithExternalJwt method sends this JWT to Dynamic’s backend, which validates the signature and issues an elevated access token.
  3. The elevated token is automatically stored in SDK state and attached to subsequent API calls — no manual token handling is needed.

Assertion JWT requirements

Your backend must sign a JWT with the following claims: Example payload:
The JWT must be signed using the same algorithm and key that corresponds to your environment’s JWKS URL.

Quick start

Combining with isStepUpRequired

Use isStepUpRequired to check whether step-up is needed before calling your backend:

Full example: credential unlinking with error handling

When to use external auth vs. other methods

Both approaches produce the same elevated access token and are stored and consumed identically by the SDK.

useExternalAuth reference

Last modified on June 25, 2026