data-fetching

Enforce Orval-generated API wrappers with TanStack Query HydrationBoundary for data fetching.

2|Updated Dec 3, 2025
One-click install
npx skills add https://github.com/atilladeniz/next-go-pg --skill data-fetching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-fetching
Source: https://github.com/atilladeniz/next-go-pg/tree/main/.claude/skills/data-fetching
Command: npx skills add https://github.com/atilladeniz/next-go-pg --skill data-fetching

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a robust and efficient strategy for data fetching in Next.js applications, eliminating common issues like UI flicker, manual API client maintenance, and complex caching. It leverages Orval and TanStack Query's HydrationBoundary pattern to ensure fast, type-safe, and real-time data delivery, saving you development time and improving user experience.

Core Features & Use Cases

  • HydrationBoundary Pattern: Implements the recommended TanStack Query pattern for server-side prefetching and client-side hydration, ensuring flicker-free initial loads.
  • Orval Integration: Enforces the use of auto-generated, type-safe API client functions, eliminating manual fetch() calls.
  • SSE for Real-Time Updates: Seamlessly integrates Server-Sent Events (SSE) with React Query to provide automatic, real-time data invalidation and updates.
  • Use Case: When building a new dashboard, use this skill to prefetch critical data on the server using Orval-generated functions, ensuring a fast, flicker-free initial load for your users, with subsequent real-time updates via SSE.

Quick Start

Explain the HydrationBoundary pattern for server-side data prefetching and client-side consumption using TanStack Query, detailing how a Server Component prefetches data and passes it to a Client Component.

Frequently Asked Questions about data-fetching

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

FAQPage Schema
How do I prevent UI flicker when prefetching data on the server in Next.js?

Use TanStack Query's HydrationBoundary pattern to prefetch data server-side with Orval-generated functions, then hydrate the client with dehydrated state. This eliminates flicker by ensuring data is available before the client renders, delivering pre-populated UI instantly.

What's the best way to fetch data in Next.js with type-safe API clients?

Orval auto-generates type-safe API client functions from your OpenAPI spec, replacing manual fetch() calls. Pair it with TanStack Query for client-side caching and server-side prefetching, ensuring consistency and eliminating runtime API errors.

How do I integrate real-time updates with Server-Sent Events in React Query?

SSE with React Query triggers automatic data invalidation and refetches through TanStack Query's mutation and query systems. This delivers live updates without polling, keeping your dashboard synchronized with backend changes in real time.

Can I use TanStack Query's HydrationBoundary with Server Components in Next.js?

Yes. Server Components prefetch data using Orval endpoints and pass dehydrated state to HydrationBoundary, which hands it to Client Components for hydration. This pattern combines server-side performance with client-side interactivity seamlessly.

Do I need manual API client maintenance if I use Orval with TanStack Query?

No. Orval auto-generates and maintains API client functions from your schema, eliminating manual fetch() code and keeping types in sync. TanStack Query handles caching and state, so you focus on UI logic instead of API plumbing.

When should I use this data-fetching pattern instead of client-side fetching?

Use server-side prefetching with HydrationBoundary for protected pages, dashboards, and critical data needing fast initial loads without flicker. Client-side fetching suits secondary data, user interactions, and scenarios where server resources are constrained.