frontend-data-layer

Manage React server state with TanStack Query v5 and typed endpoints.

3|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/The13thNode/VibeCorp_PromptCEO --skill frontend-data-layer-the13thnode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-data-layer
Source: https://github.com/The13thNode/VibeCorp_PromptCEO/tree/main/skills/public/frontend-data-layer
Command: npx skills add https://github.com/The13thNode/VibeCorp_PromptCEO --skill frontend-data-layer-the13thnode

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill standardizes how the frontend fetches, caches, and manages server state so teams stop scattering fetch logic across components and relying on fragile useState/useEffect patterns.

Core Features & Use Cases

  • TanStack Query integration: centralized QueryClient defaults for stale time, cache retention, retries, and refetch behavior.
  • API layer abstraction & TypeScript: single apiRequest entrypoint for consistent headers, error handling, and typed endpoints for listings, bookings, and auth.
  • Mutation & UX rules: mutation patterns with invalidateQueries, optimistic update guidance, and three-state page handling (loading skeleton, retryable error, empty state).
  • Use Case: implement a BrowsePage that uses a typed useListings hook with filter-aware queryKeys, shows skeletons while loading, handles errors with retry, and invalidates bookings after mutations.

Quick Start

Configure a QueryClient, implement src/lib/api.ts as the sole request layer with token injection and error parsing, then create a typed useListings hook that queries /api/listings with filter-aware queryKeys.

Frequently Asked Questions about frontend-data-layer

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

FAQPage Schema
What is the best way to replace scattered fetch logic and useState patterns with TanStack Query in React?

TanStack Query replaces scattered fetch logic by providing structured server-state management through a centralized apiRequest entrypoint, enforced queryKey consistency, and standardized caching policies, moving away from fragile useState and useEffect patterns.

How do I implement typed TypeScript endpoints for API listings and authentication flows in React?

Implement a single apiRequest entrypoint layer with typed TypeScript endpoints to handle listings, bookings, and authentication flows. This abstraction ensures consistent headers, centralized error parsing, and typed responses across your React application.

How do I handle optimistic updates and cache invalidation after mutations in React using TanStack Query?

Handle optimistic updates and cache invalidation by applying TanStack Query mutation patterns that utilize invalidateQueries. This approach automatically refetches affected data, such as invalidating bookings after a mutation, ensuring UI consistency.

Does this server-state management approach support three-state page handling for loading, error, and empty UI?

Yes, this server-state management approach enforces three-state page handling by standardizing loading skeletons, retryable error states, and empty states. This ensures consistent UX across React components during data fetching and mutation processes.

How do I configure filter-aware queryKeys for a React data fetching hook?

Configure filter-aware queryKeys by creating typed hooks, such as a useListings hook, that pass filter parameters directly into the queryKey array. This ensures TanStack Query caches and refetches data accurately based on active filters.

Why does my React component keep refetching data instead of using the TanStack Query cache?

Your component keeps refetching data instead of using the TanStack Query cache due to inconsistent queryKeys or unconfigured QueryClient defaults. Enforcing centralized stale time, cache retention, and refetch behavior policies resolves this server-state issue.