Order Hooks
Create orders, get quotes, track payments
Payment Hooks
Direct transfers, gas prices
Fiat & Onramp
Stripe, Coinbase, geo-based options
Order hooks
useAnyspendQuote
Get real-time pricing for token swaps and cross-chain transactions. Quotes auto-refresh every 10 seconds.
Basic Usage
Parameters
QuoteRequest
required
Quote configuration object
QuoteRequest
Returns
QuoteResponse | null
Quote data with pricing, fees, and expected output
boolean
Loading state
Error | null
Error if quote request failed
() => void
Manually refresh the quote
Example
Swap Quote Preview
useAnyspendCreateOrder
Create and execute AnySpend orders for crypto payments.
Basic Usage
Parameters
UseAnyspendCreateOrderProps
Configuration with callback functions
UseAnyspendCreateOrderProps
Returns
(params: CreateOrderParams) => void
Function to create an order
boolean
Loading state
CreateOrderParams
Example
Payment Form
useAnyspendCreateOnrampOrder
Create orders for fiat onramp payments (Stripe, Coinbase Pay).
Basic Usage
Parameters
UseAnyspendCreateOnrampOrderProps
Returns
(params: CreateOnrampOrderParams) => void
Function to create a fiat onramp order
boolean
Loading state
CreateOnrampOrderParams
Order tracking hooks
useAnyspendOrderAndTransactions
Monitor order status and track associated blockchain transactions in real-time.
Basic Usage
Parameters
string
required
Order ID to track
Returns
OrderWithTransactions | null
Complete order data with transaction details
boolean
Loading state
Error | null
Error if fetch failed
OrderWithTransactions
Example
Order Tracker
useAnyspendOrderHistory
Retrieve paginated order history for a user address.
Basic Usage
Parameters
string
required
User wallet address
number
required
Number of orders to fetch (max 100)
number
required
Pagination offset
Token and chain hooks
useAnyspendTokens
Fetch available tokens for a specific chain with optional search.
Basic Usage
Parameters
number
required
Chain ID to fetch tokens for
string
Optional search filter (token name or symbol)
useGasPrice
Fetch real-time gas prices for a chain with spike detection.
Basic Usage
Parameters
number
Chain ID to fetch gas price for
UseGasPriceOptions
Optional configuration
UseGasPriceOptions
Returns
GasPriceData | undefined
Gas price data including fast, standard, and slow estimates
boolean
Loading state
boolean
Whether gas is currently spiking above normal levels
boolean
Whether there’s an error
Error | null
Error object
() => void
Manually refresh gas price
Payment hooks
useDirectTransfer
Execute direct transfers when source and destination token/chain match, bypassing the swap backend for faster, cheaper transactions.
Basic Usage
Returns
(params: DirectTransferParams) => Promise<string | undefined>
Execute a direct transfer. Returns the transaction hash on success.
boolean
Loading state
DirectTransferParams
Example
Direct Transfer
Fiat and onramp hooks
useGeoOnrampOptions
Get all available onramp options based on the user’s geographic location. Combines geo detection, Coinbase availability, and Stripe support.
Basic Usage
Parameters
string
required
The fiat amount for the onramp (e.g.,
"50")Returns
boolean
Whether any fiat onramp is available for the user’s location
object
Coinbase Pay configuration and available payment methods
array
Available Coinbase payment methods for the user’s region
boolean
Whether Stripe redirect flow is supported
object
Whether Stripe embedded form is supported (
{ isSupport: boolean })boolean
Combined loading state
object
User’s detected geographic data (country, city, timezone)
useCoinbaseOnrampOptions
Get Coinbase Pay onramp configuration for fiat payments.
Basic Usage
Parameters
string
ISO country code (e.g.,
"US")useStripeSupport
Check Stripe payment availability based on the user’s location and payment amount.
Basic Usage
Parameters
string
USD amount for the payment
VisitorData
Fingerprint.js visitor data (optional, for fraud detection)
boolean
Whether visitor data is still loading
Returns
boolean
Whether Stripe redirect flow is available
{ isSupport: boolean }
Whether Stripe embedded form is available
boolean
Loading state
useStripeClientSecret
Get a Stripe client secret for initializing the embedded Stripe payment form.
Basic Usage
Checkout session hooks
useCreateCheckoutSession
Create a checkout session for backend-tracked payment flows.
Basic Usage
useCheckoutSession
Query a checkout session with automatic polling. Stops polling when status reaches complete or expired.
Basic Usage
Parameters
string
required
Checkout session ID to track
Returns
CheckoutSession
Session data including
status, order_id, metadataboolean
Loading state
Example
Session Tracker
Hook patterns
Error handling
Error Handling Pattern
Composing loading states
Combined Loading States
Next steps
Components
Pre-built components using these hooks
Examples
Real-world implementation examples
Error Handling
Comprehensive error handling guide
HypeDuel