useQuote
TheuseQuote 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
enabledto pause/resume automatic fetching
Basic Usage
Form Integration
Integrate with form inputs for a complete bridge interface:Conditional Fetching
Use theenabled parameter to control when quotes are fetched:
Route Preferences
Choose how routes are selected:Manual Refetch
Userefetch to manually trigger a new quote:
Manual
refetch bypasses the debounce timer and fetches immediately.Best Practices
Performance and UX Tips:
- Debouncing is automatic - The hook waits 500ms after the last parameter change before fetching. Do not add your own debounce.
- Handle all states - Always render appropriate UI for loading, error, and empty states.
-
Use
enabledwisely - Disable fetching when the user hasn’t entered valid input yet. - Validate amounts - Ensure the amount is a valid positive number before enabling the hook.
- 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
