nextjs-data-fetching
Skill2 starsChanged 4 months agoMITView on GitHub
Fetch and mutate data in Next.js App Router with correct caching, Server Actions boundaries, and loading/error UX. Use when implementing Next.js data fetching, caching, revalidation, Server Actions, route handlers, or fixing stale/over-fetched data in Next apps.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- FilippoDeSilva/skillstheir own version, first seen Jun 26, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- FilippoDeSilva/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- debuggingSkill
- javascript-best-practicesSkill
- nextjs-app-routerSkill
- python-best-practicesSkill
- python-testingSkill
- react-best-practicesSkill
- tagged-code-commentsSkill
- typescript-best-practicesSkill
- create-skillSkill
- revise-skillSkill
- academic-paperSkill
- latex-scientific-writingSkill
- paper-abstractSkill
- paper-conclusionSkill
- paper-discussionSkill
- paper-introductionSkill
- paper-literature-reviewSkill
- paper-methodsSkill
- paper-peer-reviewSkill
- paper-related-workSkill
- paper-resultsSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Use Server Actions for mutations from the client when the project uses them
- Distinctive: line 21
Prefer explicit cache/revalidate choices over accidental defaults
- Very specific: line 30
Loading and errors: Use loading.tsx, route-level error.tsx, or Suspense boundaries so users see progress and recoverable failures.
- Distinctive: line 31
Client fetching only when needed: Use client SWR/React Query (if present) for highly interactive, frequently updating client state — not as …
- Distinctive: line 32
Match auth boundaries: Check session/permissions before returning sensitive data or performing mutations.
- Very specific: line 33
Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, 🔴 SECURITY(P0):).
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Next.js Data Fetching
Defaults
- Fetch in Server Components when data is needed for render
- Use Server Actions for mutations from the client when the project uses them
- Prefer explicit cache/revalidate choices over accidental defaults
- Pair slow fetches with
loading.tsx/ Suspense
Instructions
- Read on the server. In Server Components,
fetch(or the project's data client) during render. Avoid waterfalls: fetch in parallel when requests are independent. - Be explicit about caching. Know whether a
fetchis cached or dynamic for the Next version in use. Setcache: 'no-store'ornext: { revalidate: N }intentionally — do not guess. - Mutations via Server Actions or route handlers. Validate input on the server. Revalidate tags/paths after successful writes (
revalidatePath/revalidateTagas appropriate). - Do not leak secrets. Server-only env vars and privileged clients stay on the server. Never expose service keys to client bundles.
- Loading and errors. Use
loading.tsx, route-levelerror.tsx, or Suspense boundaries so users see progress and recoverable failures. - Client fetching only when needed. Use client SWR/React Query (if present) for highly interactive, frequently updating client state — not as the default for initial page data.
- Match auth boundaries. Check session/permissions before returning sensitive data or performing mutations.
- Tag unfinished or risky work. Use the global
tagged-code-commentsconvention (🔴 FIXME(P0):,🟠 TODO(P1):,🔴 SECURITY(P0):). Never leave silent stubs or insecure shortcuts. End with an Open follow-ups table so the developer must check P0/P1 before ship.
Patterns
// Server Component — intentional revalidation
async function Products() {
const res = await fetch("https://api.example.com/products", {
next: { revalidate: 60 },
});
if (!res.ok) throw new Error("Failed to load products");
const products = await res.json();
return <ProductList products={products} />;
}"use server";
import { revalidatePath } from "next/cache";
export async function createItem(formData: FormData) {
const title = String(formData.get("title") ?? "").trim();
if (!title) throw new Error("Title required");
// await db.insert...
revalidatePath("/items");
}Anti-patterns
- Fetching the same data in many nested clients instead of once on the server
- Ignoring auth on Server Actions
- Returning large unneeded payloads to the client
- Mixing Pages Router data APIs into App Router
Additional resources
- references/checklist.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

