data-client-react

Implements React data fetching, mutations, and subscriptions using @data-client/react hooks.

2.0k|99|Updated Feb 15, 2019
One-click install
npx skills add https://github.com/reactive/data-client --skill data-client-react
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-client-react
Source: https://github.com/reactive/data-client/tree/main/.agents/skills/data-client-react
Command: npx skills add https://github.com/reactive/data-client --skill data-client-react

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @data-client/react, and includes references (resource) components.

What problem does it solve?

Wiring React components to remote APIs usually requires manual loading states, error handling, cache management, and optimistic update logic. This Skill provides idiomatic patterns for @data-client/react so data fetching, mutations, and real-time subscriptions work with automatic normalization and caching.

Core Features & Use Cases

  • Declarative data rendering: Use useSuspense, useFetch, useQuery, useCache, useLive, and useDLE to read remote data with Suspense, parallel fetches via React.use(), or explicit loading/error states.
  • Type-safe mutations: Perform creates, updates, partial updates, deletes, and pagination through useController with automatic cache updates and optimistic responses.
  • Real-time and debugging support: Add polling, websocket, or SSE subscriptions with useSubscription, and inspect store state or dispatch Controller actions from Chrome DevTools MCP.
  • Use Case: Building a todo list page that fetches todos with useSuspense, adds items with ctrl.fetch(TodoResource.getList.push), and wraps everything in an AsyncBoundary for loading and error states.

Quick Start

Use the data-client-react skill to build a React component that fetches and renders a todo list with useSuspense and supports adding new todos through useController.

Frequently Asked Questions about data-client-react

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch data in React with useSuspense?

Call useSuspense with an endpoint and its params, like useSuspense(TodoResource.get, { id: 5 }), and the component suspends until data arrives. Wrap the tree in AsyncBoundary to handle loading and error states declaratively.

How do I perform mutations with @data-client/react?

Get the Controller via useController and call ctrl.fetch with a mutation endpoint, such as ctrl.fetch(TodoResource.update, { id }, todo). The normalized cache updates automatically, and collection endpoints like getList.push handle list insertion.

What is the difference between useSuspense, useDLE, and useCache?

useSuspense fetches and suspends rendering until data is ready. useDLE fetches without Suspense and returns { data, loading, error } for manual state handling. useCache reads existing cache without triggering a fetch and may return null.

Does @data-client/react support websockets and server-sent events?

Yes, useSubscription and useLive support polling, websocket, and SSE updates through custom Managers. useLive combines fetching with subscription so components stay updated as server data changes.

How do I debug @data-client/react store state in the browser?

In dev mode, DevToolsManager exposes controllers on globalThis.__DC_CONTROLLERS__, accessible via Chrome DevTools MCP evaluate_script. You can inspect entities, endpoint metadata, track dispatched actions, and call Controller methods like invalidate or resetEntireStore.

When should I not hide data fetching inside custom hooks?

The skill recommends co-locating useSuspense or useDLE calls in the component that renders the data rather than wrapping them in custom hooks. Hiding bindings obfuscates data dependencies; reusable transformations belong in Query schemas instead.