Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply 62 React and Next.js performance optimization rules from Vercel Engineering
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/server-parallel-fetching.md
1---2title: Parallel Data Fetching with Component Composition3impact: CRITICAL4impactDescription: eliminates server-side waterfalls5tags: server, rsc, parallel-fetching, composition6---78## Parallel Data Fetching with Component Composition910React Server Components execute sequentially within a tree. Restructure with composition to parallelize data fetching.1112**Incorrect (Sidebar waits for Page's fetch to complete):**1314```tsx15export default async function Page() {16const header = await fetchHeader()17return (18<div>19<div>{header}</div>20<Sidebar />21</div>22)23}2425async function Sidebar() {26const items = await fetchSidebarItems()27return <nav>{items.map(renderItem)}</nav>28}29```3031**Correct (both fetch simultaneously):**3233```tsx34async function Header() {35const data = await fetchHeader()36return <div>{data}</div>37}3839async function Sidebar() {40const items = await fetchSidebarItems()41return <nav>{items.map(renderItem)}</nav>42}4344export default function Page() {45return (46<div>47<Header />48<Sidebar />49</div>50)51}52```5354**Alternative with children prop:**5556```tsx57async function Header() {58const data = await fetchHeader()59return <div>{data}</div>60}6162async function Sidebar() {63const items = await fetchSidebarItems()64return <nav>{items.map(renderItem)}</nav>65}6667function Layout({ children }: { children: ReactNode }) {68return (69<div>70<Header />71{children}72</div>73)74}7576export default function Page() {77return (78<Layout>79<Sidebar />80</Layout>81)82}83```84