server-parallel-fetching — Claude Code rule for data fetching
The server-parallel-fetching rule shows how to compose React Server Components so independent data requests can run in parallel. Use it when one component waits on another component’s fetch.
MIT ★ 7,191 updated 2026-10-24
.claude/rules/server-parallel-fetching.mdWhat server-parallel-fetching does
In a React Server Component tree, a page can finish fetching its header before its sidebar starts requesting data. This rule restructures the example: Header and Sidebar each load their own data, and the page renders them as siblings.
It also demonstrates a children pattern, with Layout rendering Header and receiving the page content as a child. That can separate independent requests; it does not remove a real dependency where one fetch needs another’s result. Check the data flow before applying the refactor.
What it helps with
- stop a sidebar fetch from waiting on the page header request
- run independent React Server Component requests in parallel
- restructure a page using component composition
- pass page content through
Layoutwithchildren
Example prompts for the agent
- Check this React Server Component page for sequential fetches and suggest a composition with
HeaderandSidebar. - Refactor this page to use
Layoutwithchildrenso independent data requests can run in parallel.
How to install server-parallel-fetching
Manually: put the files in place
.claude/rules/server-parallel-fetching.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/server-parallel-fetching.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/server-parallel-fetching.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/server-parallel-fetching.mdManually: put the files in place
.clinerules/server-parallel-fetching.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about server-parallel-fetching
How do I install server-parallel-fetching in Claude Code?
Add the rule to your project at .claude/rules/server-parallel-fetching.md.
What does server-parallel-fetching do?
It shows how to compose React Server Components so independent data loads can run alongside each other instead of forming a wait chain.
Can the children pattern parallelize dependent requests?
No. It can separate independent loads by placing Header and the page content under Layout; a request that needs another request’s result still depends on it.
Source text
server-parallel-fetching.md · MIT
---
title: Parallel Data Fetching with Component Composition
impact: CRITICAL
impactDescription: eliminates server-side waterfalls
tags: server, rsc, parallel-fetching, composition
---
## Parallel Data Fetching with Component Composition
React Server Components execute sequentially within a tree. Restructure with composition to parallelize data fetching.
**Incorrect (Sidebar waits for Page's fetch to complete):**
```tsx
export default async function Page() {
const header = await fetchHeader()
return (
<div>
<div>{header}</div>
<Sidebar />
</div>
)
}
async function Sidebar() {
const items = await fetchSidebarItems()
return <nav>{items.map(renderItem)}</nav>
}
```
**Correct (both fetch simultaneously):**
```tsx
async function Header() {
const data = await fetchHeader()
return <div>{data}</div>
}
async function Sidebar() {
const items = await fetchSidebarItems()
return <nav>{items.map(renderItem)}</nav>
}
export default function Page() {
return (
<div>
<Header />
<Sidebar />
</div>
)
}
```
**Alternative with children prop:**
```tsx
async function Header() {
const data = await fetchHeader()
return <div>{data}</div>
}
async function Sidebar() {
const items = await fetchSidebarItems()
return <nav>{items.map(renderItem)}</nav>
}
function Layout({ children }: { children: ReactNode }) {
return (
<div>
<Header />
{children}
</div>
)
}
export default function Page() {
return (
<Layout>
<Sidebar />
</Layout>
)
}
```
© tech-leads-club · MIT · tech-leads-club/agent-skills