Hooks
usePrice
Fetch a lightweight quote to preview route pricing
Parameters
Parameter | Description | Required |
---|---|---|
client | A RelayClient instance. You can create one using the SDK or retrieve one using the useRelayClient hook from the UI kit. | ✅ |
options | Options that map directly to the price API. | ✅ |
onResponse | A callback function that triggers when a response is returned. | ❌ |
queryOptions | Tanstack query options. Refer to the Tanstack docs. | ❌ |
Return Data
The hook returns an object with the base Tanstack Query response. The data returned will be the response from the price API.
Usage
Query Function
import { queryPrice } from "@reservoir0x/relay-kit-hooks";
const response = queryPrice("https://api.relay.link", {
user: address,
originChainId: 1,
destinationChainId: 10,
originCurrency: "0x0000000000000000000000000000000000000000",
destinationCurrency: "0x0000000000000000000000000000000000000000",
tradeType: "EXACT_INPUT",
amount: "10000000",
});