Rpc Hooks
Sui dApp Kit ships with hooks for each of the RPC methods defined in the JSON RPC specification.
useSuiClientQuery
Load data from the Sui RPC using the useSuiClientQuery
hook. This hook is a wrapper around the
useQuery hook from
@tanstack/react-query.
The hook takes the RPC method name as the first argument and any parameters as the second argument.
You can pass any additional useQuery
options as the third argument. You can read the
useQuery documentation for more
details on the full set of options available.
useSuiClientQueries
You can fetch a variable number of Sui RPC queries using the useSuiClientQueries
hook. This hook
is a wrapper around the
useQueries hook from
@tanstack/react-query.
The queries
value is an array of query option objects identical to the useSuiClientQuery
hook.
The combine
parameter is optional. Use this parameter to combine the results of the queries into a
single value. The result is structurally shared to be as referentially stable as possible.
useSuiClientInfiniteQuery
For RPC methods that support pagination, dApp Kit also implements a useSuiClientInfiniteQuery
hook. For more details check out the
useInfiniteQuery
documentation.
useSuiClientMutation
For RPC methods that mutate state, dApp Kit implements a useSuiClientMutation
hook. Use this hook
with any RPC method to imperatively call the RPC method. For more details, check out the
useMutation
documentation.
useResolveSuiNSName
To get the SuiNS name for a given address, use the useResolveSuiNSName
hook.