Skip to main content

Recommended: JavaScript SDK for React Native

While this SDK is still supported, we recommend using newer JavaScript SDK, which is optimized for React Native, but also comes with a host of other benefits.

waitForAuthSuccess

Returns a promise that resolves with the authenticated user once the authSuccess event fires. Use this when you need to ensure authentication is fully complete — including MFA and other intermediate steps — before proceeding (for example, before loading wallets or accessing user data). Before this: set up the Dynamic client (see Setting up the Dynamic Client).

Why use this instead of listening to events?

Listening for authSuccess with dynamicClient.auth.on works, but it requires manual cleanup and doesn’t handle edge cases like MFA flows where authentication pauses for user input. waitForAuthSuccess wraps this into a single promise that:
  • Resolves when authentication completes (even after MFA or other intermediate steps)
  • Rejects when authentication fails or is cancelled
  • Supports an optional timeout

Usage

Parameters

Pass options as an object:

Returns

Promise<UserProfile> — Resolves with the authenticated user profile.

Behavior

  • User not yet authenticated: Listens for authSuccess and resolves when it fires. If authFailed fires first, the promise rejects.
  • User already authenticated: Waits briefly (500 ms grace period) for an incoming authSuccess event. If no event arrives, resolves with the current authenticated user. This handles the case where authentication completed moments before the call.
  • Timeout: If timeout is set and neither authSuccess nor authFailed fires within that window, the promise rejects with a timeout error.

Examples

Wait for authentication before loading wallets

React Native

Error handling

The promise rejects in three cases:
  • Listening to events — Subscribe to individual client events
  • Auth module events — Full list of auth events including authSuccess and authFailed
  • MFA — MFA flows that complete before authSuccess fires
Last modified on July 24, 2026