Swap component handles cross-chain token exchanges. It supports exact-input (user specifies how much to spend) and exact-output (user specifies how much to receive) modes, and automatically routes across bridges and DEXs for the best price.
Basic usage
Exact input vs. exact output
Headless with useQuote
To build your own UI and manage quote refresh yourself:Props reference
| Prop | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your API key |
from.token | string | No | Source ERC20 symbol or address |
from.chain | string | number | No | Source chain |
from.amount | string | No | Amount to spend (exact input) |
to.token | string | No | Destination ERC20 symbol or address |
to.chain | string | number | No | Destination chain |
to.amount | string | No | Amount to receive (exact output) |
slippageTolerance | string | number | No | Slippage tolerance; default from provider config |
swapProvider | string | No | Preferred DEX provider |
bridgeProvider | string | No | Preferred bridge provider |
paymentMethod | string | No | Pre-select funding method |
onSwapStart | function | No | Called when the user begins |
onSwapSuccess | function | No | Called on completion |
onSwapError | function | No | Called on failure |