diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index ef4e75999c..f5af92bef0 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -17,6 +17,7 @@ sidebar_position: 1 - [`useFlowConfig`](#useflowconfig) – Access the current Flow configuration - [`useFlowEvents`](#useflowevents) – Subscribe to Flow events in real-time - [`useFlowQuery`](#useflowquery) – Execute Cadence scripts with optional arguments +- [`useFlowQueryRaw`](#useflowqueryraw) – Execute Cadence scripts with optional arguments returning non-decoded data - [`useFlowMutate`](#useflowmutate) – Send transactions to the Flow blockchain - [`useFlowRevertibleRandom`](#useflowrevertiblerandom) – Generate pseudorandom values tied to block height - [`useFlowTransactionStatus`](#useflowtransactionstatus) – Track transaction status updates @@ -314,6 +315,51 @@ function QueryExample() { --- +### `useFlowQueryRaw` + +```tsx +import { useFlowQueryRaw } from "@onflow/kit" +``` + +This hook is identical to `useFlowQuery` but returns the raw, non-decoded response data from the Flow blockchain. This is useful when you need access to the original response structure or want to handle decoding manually. + +#### Parameters: + +- `cadence: string` – Cadence script to run +- `args?: (arg, t) => unknown[]` – Function returning FCL arguments +- `query?: UseQueryOptions` – Optional TanStackQuery options + +#### Returns: `UseQueryResult` + +The returned data will be in its raw, non-decoded format as received from the Flow access node. + +```tsx +function QueryRawExample() { + const { data: rawData, isLoading, error, refetch } = useFlowQueryRaw({ + cadence: ` + access(all) + fun main(a: Int, b: Int): Int { + return a + b + } + `, + args: (arg, t) => [arg(1, t.Int), arg(2, t.Int)], + query: { staleTime: 10000 }, + }) + + if (isLoading) return

Loading query...

+ if (error) return

Error: {error.message}

+ + return ( +
+

Raw Result: {JSON.stringify(rawData, null, 2)}

+ +
+ ) +} +``` + +--- + ### `useFlowMutate` ```tsx