Skip to content
Back to skills

Nextjs Data Fetching

ASecurity

Chooses server components, caching and revalidation for each data need in the Next.js App Router, and fixes slow or stale pages.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsshellnextjs

Works with

  • cli

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill nextjs-data-fetching --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs Data Fetching?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nextjs Data Fetching
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-nextjs-data-fetching/badge)](https://www.skillsdirectory.com/skills/workspace-templates-nextjs-data-fetching)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nextjs-data-fetching
description: Chooses server components, caching and revalidation for each data need in the Next.js App Router, and fixes slow or stale pages.
---

# Next.js data fetching

Decide the freshness of each piece of data first; the code follows from that.

## Steps

1. Check the Next.js version in package.json and read its docs for caching defaults; they differ between 14 and 15 and later. Do not rely on memory.
2. For each data need ask: who sees it (everyone or one user), how fresh must it be (never changes, minutes, instant), and what changes it. Then choose:
   - Same for everyone and rarely changes: static, with `revalidate` seconds or tag-based revalidation.
   - Same for everyone but changes on events: tag the fetch and call `revalidateTag` or `revalidatePath` from the mutation.
   - Per user or per request (cookies, headers, searchParams): dynamic; keep it in a small component behind `<Suspense>`.
3. Fetch in server components with `async`/`await`. Start independent requests together with `Promise.all`; never await them in sequence. Pass promises down and unwrap them with `use` where useful.
4. Wrap slow sections in `<Suspense fallback>` with a `loading.tsx` so the shell streams first.
5. Deduplicate: call the same data function in several components freely, wrap non-fetch calls (ORM, SDK) in `cache()`.
6. Mutations use Server Actions or route handlers, validate input, and then revalidate the affected tags or paths.
7. Use client components only for interactivity. Fetch in them with a query library, and pass server-fetched initial data as props.
8. Check the build output: it lists which routes are static, dynamic or ISR. Confirm it matches the plan.

## Rules

- Never put secrets or server-only imports in client components; use `server-only`.
- Do not use `force-dynamic` to hide a caching bug.

## Report

A table of data, freshness choice, and invalidation, plus the build route summary.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.