Skip to main content

Documentation Index

Fetch the complete documentation index at: https://kubo-47e69177.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

useActionQuery

Signature

packages/query/src/useActionQuery.ts
export function useActionQuery<TInput, TOutput, TError = unknown, TData = TOutput>(
  action: DefinedAction<TInput, TOutput>,
  options: UseActionQueryOptions<TInput, TOutput, TError, TData>
): UseQueryResult<TData, TError>

Required options

OptionTypeNotes
inputTInputInput passed to the action
queryKeyQueryKeyReact Query cache key
readPolicy"read-only"Required guardrail

Behavior

  • Throws if readPolicy is not "read-only".
  • Calls action inside queryFn.
  • Passes all other options to useQuery.

Example

components/todo-list.tsx
"use client";

import { useActionQuery } from "@zapaction/query";

import { listTodos } from "../app/actions";

const query = useActionQuery(listTodos, {
  input: {},
  queryKey: ["todos"],
  readPolicy: "read-only",
  staleTime: 30_000
});