Skip to main content

Overview

The useBluvoFlow hook from @bluvo/react is powered by a finite state machine that orchestrates the entire withdrawal lifecycle, from exchange selection through OAuth, wallet loading, quoting, and withdrawal execution (including 2FA). Every state transition is deterministic: given a state and an action, the next state is always predictable. Your UI renders based on the current state. The hook exposes each state as a boolean property (e.g., flow.isOAuthPending, flow.requires2FA), so you never need to inspect raw state strings directly.
If you’re implementing OAuth for the first time, start with OAuth2 Integration for a step-by-step walkthrough. This page is a reference for when you need to look up specific states, booleans, or transitions.

Flow Diagram

Happy Path (OAuth)

Happy Path (QR Code Login)

Withdrawal Sub-Flow


States by Phase

Idle


Exchanges

listExchanges() manages its own loading state independently of the flow machine. You can call it before starting a flow, isExchangesReady becomes true when either the machine or the standalone call has data.

OAuth

Compound booleans:
  • isOAuthPending = oauth:waiting OR oauth:processing
  • isOAuthError = oauth:error OR oauth:fatal
  • isWalletConnectionInvalid = oauth:fatal OR qrcode:fatal

QR Code

Used for exchanges that support QR-based login (e.g., Binance mobile app scanning). Compound booleans:
  • isQRCodePending = any qrcode:* state except error, fatal, timeout
  • isQRCodeError = qrcode:error OR qrcode:fatal
Context data available:
  • qrCodeUrl, the URL to render as a QR code
  • qrCodeExpiresAt, Unix timestamp (ms) when the QR code expires
  • qrCodeStatus, current status string from the exchange
  • isQRCodeFlow, true when using QR code auth instead of OAuth popup
After a successful QR code scan, the flow transitions to oauth:completed and reuses the same wallet-loading path as OAuth. From wallet:loading onward, the flow is identical regardless of authentication method.

Wallet

Error detection helpers:
  • hasWalletNotFoundError, wallet ID no longer valid (deleted or expired)
  • hasInvalidCredentialsError, exchange tokens revoked; user must re-authenticate

Quote

Error detection helpers:
  • hasAmountError, amount below minimum or above maximum
  • hasAddressError, invalid destination address format
  • hasNetworkError, unsupported or invalid network
Quotes have a TTL (check quote.expiresAt). If autoRefreshQuotation is enabled in options, the hook automatically requests a fresh quote before expiry.

Withdrawal

Compound booleans:
  • isWithdrawing = any withdraw:* state that is active (not completed, fatal, or error states)
  • requiresValid2FAMethod = withdraw:fatal AND errorDetails.valid2FAMethods is present
withdraw:error2FA and withdraw:error2FAMultiStep are mutually exclusive and exchange-specific. See Error Handling & 2FA for the full breakdown.

Flow Control

cancel() can be called from any state. It disposes the withdrawal machine and resets to flow:cancelled.

Hook Booleans Quick Reference

General

Exchanges

OAuth

QR Code

Wallet

Quote

Withdrawal

Multi-Step 2FA


Context Data Reference

The flow.context object (and shortcut properties on the hook return) carry data through the flow:

Multi-Step 2FA Context

When requires2FAMultiStep is true, the multiStep2FA object is populated:

Actions Reference

All actions are async callbacks returned by the useBluvoFlow hook.

Next Steps

Error Handling & 2FA

Error recovery patterns, exchange-specific 2FA behavior, and multi-step MFA deep dive

OAuth2 Integration

Step-by-step implementation guide with React and Next.js

Code Samples

Full working examples for Next.js, React, and more

Wallet ID

How to generate and manage wallet IDs for your users