Skip to main content

useQuote

The useQuote hook fetches bridge quotes with built-in debouncing, automatic refetching when parameters change, and proper loading state management.

Import

Signature

Parameters

UseQuoteParams

Returns

UseQuoteReturn

Features

  • 500ms debounce - Prevents excessive API calls when parameters change rapidly
  • Auto-refetch - Automatically fetches a new quote when any parameter changes
  • Stale-while-revalidate - Keeps the previous quote visible during refetch
  • Controlled fetching - Use enabled to pause/resume automatic fetching

Basic Usage

Form Integration

Integrate with form inputs for a complete bridge interface:

Conditional Fetching

Use the enabled parameter to control when quotes are fetched:

Route Preferences

Choose how routes are selected:

Manual Refetch

Use refetch to manually trigger a new quote:
Manual refetch bypasses the debounce timer and fetches immediately.

Best Practices

Performance and UX Tips:
  1. Debouncing is automatic - The hook waits 500ms after the last parameter change before fetching. Do not add your own debounce.
  2. Handle all states - Always render appropriate UI for loading, error, and empty states.
  3. Use enabled wisely - Disable fetching when the user hasn’t entered valid input yet.
  4. Validate amounts - Ensure the amount is a valid positive number before enabling the hook.
  5. Keep quotes fresh - Quotes expire. Consider auto-refreshing or prompting users to refresh before execution.

Error Handling

Next Steps

useTokenBalance

Track wallet token balances

useTransactionStatus

Monitor transaction progress