Agent skill

Nextjs Data Fetching

by giuseppe-trisciuoglio in giuseppe-trisciuoglio/developer-kit

Provides Next.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error…

MITAuto-check: notesBackend & APIs

Install Nextjs Data Fetching

skills CLI
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-data-fetching -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install giuseppe-trisciuoglio/developer-kit nextjs-data-fetching --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/developer-kit-typescript/skills/nextjs-data-fetching .claude/skills/nextjs-data-fetching && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
nextjs-data-fetching
GitHub stars
357
Token cost
~2.2k tokens
SKILL.md length
446 words
Files
8 (incl. references)
Skills in repo
115
Repo updated
First seen
Licence
MIT

At a glance

Provides Next.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error…

  • Works in 7 steps: Default to Server Components — Fetch in… → Use parallel fetching — Promise.all()… → Choose appropriate caching → …
  • Implementing data fetching in Next.js applications
  • SKILL.md covers Overview, When to Use, Instructions and Client-Side Data Fetching, plus 6 more sections
  • Calls npm

What it does

Nextjs Data Fetching is an agent skill from giuseppe-trisciuoglio/developer-kit. Provides Next.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error boundaries. Use when implementing data fetching in Next.js applications, choosing between server and client fetching, setting up caching strategies, or handling loading and error states.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 8 other files, including reference files (for example `references/caching-strategies.md`, `references/client-fetching.md` and `references/data-fetching.md`).

It sits in Backend & APIs, covering Error handling and Caching. It works with Next.js and TanStack. The repository describes itself as: Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI. The licence is MIT.

When your agent uses it

  • Implementing data fetching in Next.js applications
  • Choosing between server and client fetching
  • Setting up caching strategies
  • Handling loading and error states

Example prompts

  • “Use the nextjs-data-fetching skill to provide Next.js App Router data fetching patterns including SWR and React Query integration, parallel data…”
  • “/nextjs-data-fetching”

Requirements

  • Node.js
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Default to Server Components — Fetch in Server Components for better performance
  2. Use parallel fetching — Promise.all() for independent requests to reduce latency
  3. Choose appropriate caching
  4. Handle errors gracefully — Wrap client data fetching in error boundaries
  5. Implement loading states — Use loading.tsx or Suspense boundaries
  6. Prefer SWR/React Query for: real-time data, user interactions, background updates
  7. Use Server Actions for: form submissions, mutations requiring cache revalidation

What it can do on your machine

Read from SKILL.md and the folder at commit fe73fb3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Nextjs Data Fetching loads about 2.2k tokens when it runs, and up to ~8.8k if it reads all its reference files. Until then it costs about 100 tokens; SKILL.md has 446 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~100
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~8.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from giuseppe-trisciuoglio/developer-kit at commit fe73fb3, republished under its MIT licence (© giuseppe-trisciuoglio). 446 words, ~2,217 tokens.

Download SKILL.mdSave it as .claude/skills/nextjs-data-fetching/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
nextjs-data-fetching
description
Provides Next.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error boundaries. Use when implementing data fetching in Next.js applications, choosing between server and client fetching, setting up caching strategies, or handling loading and error states.
allowed-tools
Read, Write, Edit, Bash

Next.js Data Fetching

Overview

Provides patterns for data fetching in Next.js App Router: server-side fetching, SWR/React Query integration, ISR, revalidation, error boundaries, and loading states.

When to Use

  • Implementing data fetching in Next.js App Router
  • Choosing between Server Components and Client Components
  • Setting up SWR or React Query for client-side caching
  • Configuring ISR, time-based, or on-demand revalidation
  • Handling loading and error states
  • Building forms with Server Actions

Instructions

Server Component Fetching

Fetch directly in async Server Components:

tsx
async function getPosts() {
  const res = await fetch('https://api.example.com/posts');
  if (!res.ok) throw new Error('Failed to fetch posts');
  return res.json();
}

export default async function PostsPage() {
  const posts = await getPosts();
  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}
Parallel Data Fetching

Use Promise.all() for independent requests:

tsx
async function getDashboardData() {
  const [user, posts, analytics] = await Promise.all([
    fetch('/api/user').then(r => r.json()),
    fetch('/api/posts').then(r => r.json()),
    fetch('/api/analytics').then(r => r.json()),
  ]);
  return { user, posts, analytics };
}

export default async function DashboardPage() {
  const { user, posts, analytics } = await getDashboardData();
  // Render dashboard
}
Sequential Data Fetching (When Dependencies Exist)
tsx
async function getUserPosts(userId: string) {
  const user = await fetch(`/api/users/${userId}`).then(r => r.json());
  const posts = await fetch(`/api/users/${userId}/posts`).then(r => r.json());
  return { user, posts };
}
Time-based Revalidation (ISR)
tsx
async function getPosts() {
  const res = await fetch('https://api.example.com/posts', {
    next: { revalidate: 60 } // Revalidate every 60 seconds
  });
  return res.json();
}
On-Demand Revalidation
tsx
// app/api/revalidate/route.ts
import { revalidateTag } from 'next/cache';
import { NextRequest } from 'next/server';

export async function POST(request: NextRequest) {
  const tag = request.nextUrl.searchParams.get('tag');
  if (tag) {
    revalidateTag(tag);
    return Response.json({ revalidated: true });
  }
  return Response.json({ revalidated: false }, { status: 400 });
}

Tag data for selective revalidation:

tsx
async function getPosts() {
  const res = await fetch('https://api.example.com/posts', {
    next: { tags: ['posts'], revalidate: 3600 }
  });
  return res.json();
}
Opt-out of Caching
tsx
async function getRealTimeData() {
  const res = await fetch('https://api.example.com/data', {
    cache: 'no-store'
  });
  return res.json();
}

// Or:
export const dynamic = 'force-dynamic';

Client-Side Data Fetching

SWR Integration

Install: npm install swr

tsx
'use client';

import useSWR from 'swr';

const fetcher = (url: string) => fetch(url).then(r => r.json());

export function Posts() {
  const { data, error, isLoading } = useSWR('/api/posts', fetcher, {
    refreshInterval: 5000,
    revalidateOnFocus: true,
  });

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Failed to load posts</div>;

  return (
    <ul>
      {data.map((post: any) => (
        <li key={post.id}>{post.title}</li>
      ))}
    </ul>
  );
}
React Query Integration

Install: npm install @tanstack/react-query

tsx
// app/providers.tsx
'use client';

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useState } from 'react';

export function Providers({ children }: { children: React.ReactNode }) {
  const [queryClient] = useState(() => new QueryClient({
    defaultOptions: {
      queries: {
        staleTime: 60 * 1000,
        refetchOnWindowFocus: false,
      },
    },
  }));

  return (
    <QueryClientProvider client={queryClient}>
      {children}
    </QueryClientProvider>
  );
}

See react-query.md for mutations, optimistic updates, infinite queries, and advanced patterns.

Error Boundaries

Wrap client-side data fetching in Error Boundaries to handle failures gracefully:

See error-boundaries.md for full ErrorBoundary implementations (basic, with reset callback) and usage examples with data fetching.

Server Actions

Use Server Actions for mutations with cache revalidation:

See server-actions.md for complete examples including form validation with useActionState, error handling, and cache invalidation.

Loading States

loading.tsx Pattern
tsx
// app/posts/loading.tsx
export default function PostsLoading() {
  return (
    <div className="space-y-4">
      {[...Array(5)].map((_, i) => (
        <div key={i} className="h-16 bg-gray-200 animate-pulse rounded" />
      ))}
    </div>
  );
}
Suspense Boundaries
tsx
// app/posts/page.tsx
import { Suspense } from 'react';
import { PostsList } from './PostsList';
import { PostsSkeleton } from './PostsSkeleton';

export default function PostsPage() {
  return (
    <div>
      <h1>Posts</h1>
      <Suspense fallback={<PostsSkeleton />}>
        <PostsList />
      </Suspense>
    </div>
  );
}

Best Practices

  1. Default to Server Components — Fetch in Server Components for better performance
  2. Use parallel fetching — Promise.all() for independent requests to reduce latency
  3. Choose appropriate caching:
    • Static data: long revalidation intervals
    • Dynamic data: short revalidation or cache: 'no-store'
    • User-specific data: use dynamic rendering
  4. Handle errors gracefully — Wrap client data fetching in error boundaries
  5. Implement loading states — Use loading.tsx or Suspense boundaries
  6. Prefer SWR/React Query for: real-time data, user interactions, background updates
  7. Use Server Actions for: form submissions, mutations requiring cache revalidation
Show full SKILL.md (167 more words)Show less

Constraints and Warnings

Critical Constraints
  • Server Components cannot use hooks (useState, useEffect) or client data fetching libraries
  • Client Components must include the 'use client' directive
  • The fetch API in Next.js extends standard Web fetch with Next.js-specific caching options
  • Server Actions require 'use server' and can only be called from Client Components or form actions
Common Pitfalls
  1. Fetching in loops — Avoid sequential fetches in Server Components; use parallel fetching
  2. Cache poisoning — Do not use force-cache for user-specific or personalized data
  3. Memory leaks — Clean up subscriptions in Client Components when using real-time data
  4. Hydration mismatches — Ensure server and client render the same initial state with React Query hydration

Examples

Example 1: Blog with ISR

Input: Create a blog page that fetches posts and updates every hour.

tsx
// app/blog/page.tsx
async function getPosts() {
  const res = await fetch('https://api.example.com/posts', {
    next: { revalidate: 3600 }
  });
  return res.json();
}

export default async function BlogPage() {
  const posts = await getPosts();
  return (
    <main>
      <h1>Blog Posts</h1>
      {posts.map(post => (
        <article key={post.id}>
          <h2>{post.title}</h2>
          <p>{post.excerpt}</p>
        </article>
      ))}
    </main>
  );
}

Output: Page statically generated at build time, revalidated every hour.

Example 2: Dashboard with Parallel Fetching

Input: Build a dashboard showing user profile, stats, and recent activity in parallel.

tsx
// app/dashboard/page.tsx
async function getDashboardData() {
  const [user, stats, activity] = await Promise.all([
    fetch('/api/user').then(r => r.json()),
    fetch('/api/stats').then(r => r.json()),
    fetch('/api/activity').then(r => r.json()),
  ]);
  return { user, stats, activity };
}

export default async function DashboardPage() {
  const { user, stats, activity } = await getDashboardData();
  return (
    <div className="dashboard">
      <UserProfile user={user} />
      <StatsCards stats={stats} />
      <ActivityFeed activity={activity} />
    </div>
  );
}

Output: All three requests execute concurrently, minimizing total load time.

© giuseppe-trisciuoglio, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in plugins/developer-kit-typescript/skills/nextjs-data-fetching of giuseppe-trisciuoglio/developer-kit.

  • SKILL.md
  • references/caching-strategies.md
  • references/client-fetching.md
  • references/data-fetching.md
  • references/error-boundaries.md
  • references/error-loading-states.md
  • references/react-query.md
  • references/server-actions.md

Open the folder on GitHubat commit fe73fb3

Compare with similar skills

Nextjs Data Fetching next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Nextjs Data Fetching compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Nextjs Data Fetching this skillgiuseppe-trisciuoglio/developer-kit357—~2.2kAutomated safety check: NotesMIT
Nextjs ExpertLeoYeAI/openclaw-master-skills2.2k—~4.8kAutomated safety check: PassMIT
Native Data FetchingCherryHQ/cherry-studio-app4k6 repos~2.9kAutomated safety check: NotesMIT
Cache Componentssangrokjung/claude-forge852—~3.7kAutomated safety check: PassMIT
iOS Networkingdpearson2699/swift-ios-skills1.2k—~4.2kAutomated safety check: PassCustom licence
Tanstack Query Best PracticesDeckardGer/tanstack-agent-skills2221 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Nextjs Expert

    LeoYeAI/openclaw-master-skills

    A skill your agent uses when building Next.js 14/15 applications with the App Router.

    2.2k GitHub stars~4.8k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Native Data Fetching

    CherryHQ/cherry-studio-app

    A skill your agent uses when implementing or debugging ANY network request, API call, or data fetching.

    4k GitHub starsUsed in 6 repos~2.9k tokens
    DevelopmentAuto-check: notes
  • Cache Components

    sangrokjung/claude-forge

    Expert guidance for Next.js Cache Components and Partial Prerendering (PPR).

    852 GitHub stars~3.7k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • iOS Networking

    dpearson2699/swift-ios-skills

    Build, review, or improve networking code in iOS/macOS apps using URLSession with async/await, structured concurrency, and modern Swift patterns.

    1.2k GitHub stars~4.2k tokensUpdated 2 mo ago
    Backend & APIsAuto-check passed
  • Tanstack Query Best Practices

    DeckardGer/tanstack-agent-skills

    TanStack Query (React Query) best practices for data fetching, caching, mutations, and server state management.

    222 GitHub starsUsed in 1 repo~1.2k tokens
    Backend & APIsAuto-check passed
  • Trpc Patterns

    FranciscoMoretti/chat-js

    Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation.

    1.2k GitHub stars~288 tokensUpdated yesterday
    Backend & APIsAuto-check passed

More from giuseppe-trisciuoglio/developer-kit

All 115 skills in this repo
  • Nestjs Drizzle Crud Generator

    giuseppe-trisciuoglio/developer-kit

    Generates complete CRUD modules for NestJS applications with Drizzle ORM.

    357 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Actuator

    giuseppe-trisciuoglio/developer-kit

    Provides patterns to configure Spring Boot Actuator for production-grade monitoring, health probes, secured management endpoints, and Micrometer metrics across JVM services.

    357 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Crud Patterns

    giuseppe-trisciuoglio/developer-kit

    Provides and generates complete CRUD workflows for Spring Boot 3 services.

    357 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Security JWT

    giuseppe-trisciuoglio/developer-kit

    Provides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based…

    357 GitHub stars~3.9k tokensUpdated 1 mo ago
    Auto-check: notes
  • AWS CLI Beast

    giuseppe-trisciuoglio/developer-kit

    Provides advanced AWS CLI patterns for managing EC2, Lambda, S3, DynamoDB, RDS, VPC, IAM, and CloudWatch.

    357 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes
  • PR Review Comments

    giuseppe-trisciuoglio/developer-kit

    Posts review findings from a JSON file as inline comments on a GitHub Pull Request, attaching each comment to its file and line.

    357 GitHub stars~1k tokensUpdated 1 mo ago
    Auto-check: notes

Works with

Questions about Nextjs Data Fetching

What does Nextjs Data Fetching do?

Provides Next.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error…. Nextjs Data Fetching is an agent skill from giuseppe-trisciuoglio/developer-kit.js App Router data fetching patterns including SWR and React Query integration, parallel data fetching, Incremental Static Regeneration (ISR), revalidation strategies, and error boundaries.

When should I use Nextjs Data Fetching?

Nextjs Data Fetching fits situations like: implementing data fetching in Next.js applications; choosing between server and client fetching; setting up caching strategies; handling loading and error states.

How do I install Nextjs Data Fetching in Claude Code?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-data-fetching -a claude-code`. Or copy the skill folder (plugins/developer-kit-typescript/skills/nextjs-data-fetching in giuseppe-trisciuoglio/developer-kit) into .claude/skills/nextjs-data-fetching in your project. Claude Code loads it when a task matches its description.

How do I install Nextjs Data Fetching in Codex?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-data-fetching -a codex`. Or copy the skill folder (plugins/developer-kit-typescript/skills/nextjs-data-fetching in giuseppe-trisciuoglio/developer-kit) into .agents/skills/nextjs-data-fetching in your project. Codex loads it when a task matches its description.

Can I use Nextjs Data Fetching in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-data-fetching -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/nextjs-data-fetching, .gemini/skills/nextjs-data-fetching, .github/skills/nextjs-data-fetching and .opencode/skills/nextjs-data-fetching in your project.

What does Nextjs Data Fetching need to run?

Going by SKILL.md and its folder, Nextjs Data Fetching needs the command-line tools its instructions call (npm). Our summary lists: Node.js. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash.

Does Nextjs Data Fetching access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Nextjs Data Fetching safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Nextjs Data Fetching use?

Nextjs Data Fetching is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Nextjs Data Fetching use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 6.6k tokens, read only when the agent opens those files.

What are the alternatives to Nextjs Data Fetching?

Skills that share tags, products or a category with Nextjs Data Fetching: Nextjs Expert (LeoYeAI/openclaw-master-skills, 2.2k stars), Native Data Fetching (CherryHQ/cherry-studio-app, 4k stars), Cache Components (sangrokjung/claude-forge, 852 stars) and iOS Networking (dpearson2699/swift-ios-skills, 1.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Nextjs Data Fetching?

giuseppe-trisciuoglio (a GitHub user) maintains it in giuseppe-trisciuoglio/developer-kit, which has 357 GitHub stars. The repository holds 115 skills in this directory. The repository was last updated on September 10, 2026.

Source: giuseppe-trisciuoglio/developer-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.