Skip to main content
Three hooks, one per @ravn/sdk call that benefits from React state: quote fetching with expiry tracking, execute as an async action, and status as a poll. You still bring your own wallet; these hooks never sign or send anything.
peer dependency
Requires React 18 or later.
peer dependency
Create one RavnClient and pass it to every hook.

useRavnQuote

Fetches whenever params changes (compared by value, not by reference, so a fresh object literal on every render is fine), and sets isExpired on its own timer when quote.expiresAt passes: no polling, one setTimeout per quote. Pass params: null to skip fetching, for example when the amount hasn’t been entered yet.
Does not auto-refetch on expiry. Silently re-pricing behind the user’s back is worse than telling them to ask again, so call refetch() yourself in response to isExpired.
QuoteDTO | null
boolean
unknown
A RavnApiError on a failed request. See Errors.
boolean
True once quote.expiresAt has passed. Stop letting the user sign, and call refetch().
() => void

useRavnExecute

A thin state wrapper around client.execute(). Branch on the returned executionType and hand it to whatever signer you already have: wagmi, ethers, a hardware wallet. Same contract as the Quickstart.
(params: ExecuteParams) => Promise<ExecutionDTO>
Also throws on failure. Handle the rejection or read error, whichever fits your flow.
ExecutionDTO | null
boolean
unknown

useRavnStatus

Polls GET /status until the status leaves pending/processing: expired, success, refunded, failed, not_found, and unknown all stop the poll. Pass params: null to not poll at all, for example before execution has produced a ref.
expired stops this hook, but it isn’t a final outcome. Per Status, a refund can still land later and flip it to refunded. This hook has no refetch, so to catch that later transition, call client.getStatus() yourself after a delay, or remount the hook.
Keeps polling through a transient network or 5xx error. Stops immediately on a permanent one, UNAUTHORIZED, INVALID_REQUEST, QUOTE_INVALID, or NOT_FOUND, since retrying with the same arguments can never turn one of those into success.
StatusDTO | null
boolean
unknown

Putting it together