---
name: "trpc-query-react-client-binding"
description: "Consume tRPC endpoints in React components with TanStack Query hooks and full autocomplete."
metadata:
  author: "tRPC"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup trpc react client"
  - "trpc.usequery react"
  - "invalidate trpc cache useutils"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# tRPC React Query Client Integration & Optimistic Hooks

Configures @trpc/react-query: creating trpc client hooks (trpc.useUtils, trpc.useQuery, trpc.useMutation), invalidating queries on mutations, setting SSR prefetching, and batching HTTP requests with httpBatchLink.

## When to Invoke
Invoke this skill whenever you need to:
- setup trpc react client
- trpc.usequery react
- invalidate trpc cache useutils

## Execution SOP & Rules
1. Create client hooks: export const trpc = createTRPCReact<AppRouter>().
2. Wrap application with <trpc.Provider client={trpcClient} queryClient={queryClient}>.
3. Configure links: [httpBatchLink({ url: '/api/trpc', headers: () => ({ ... }) })].
4. Call procedures with full IDE type autocomplete on procedure names and argument parameters.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
