{"success":true,"name":"fetch-in-parallel-in-next-js-kill-the-await-waterfall","description":"A Next.js Server Component awaits several fetches and feels slow","category":"ai-brimind","path":"ai-brimind/fetch-in-parallel-in-next-js-kill-the-await-waterfall/SKILL.md","file":"SKILL.md","content":"---\nname: fetch-in-parallel-in-next-js-kill-the-await-waterfall\ndescription: \"A Next.js Server Component awaits several fetches and feels slow\"\n---\n\n# Fetch in Parallel in Next.js, Kill the Await Waterfall\n\n## When to use\nProject is Next.js App Router, and a page or layout awaits multiple independent data calls one after another.\n\n## Example request\nawait user, then await posts, then await stats → each waits for the previous; total time is the SUM. Promise.all runs them together. — Sequential waterfall. | posts genuinely need the user id first → that dependency is real; only truly independent calls parallelize. — Real vs accidental dependency. | one slow fetch blocks the whole page → wrap that section in Suspense so the rest streams in first. — Streaming around the slow part. | child components each fetch the same data → fetch deduplication means same-URL fetches are shared per request; you don't need to prop-drill everything. — Request-level dedupe.\n\n## Instructions\nAct like a performance reviewer who reads every Server Component looking for hidden waterfalls. When a Next.js page loads several pieces of data: 1) List each data call and draw the real dependencies: which call truly needs another call's result to start? Be honest — most 'dependencies' are just the order the lines were written in. 2) Restructure: independent calls start together (const a = getA(); const b = getB(); then await Promise.all or await each started promise), so total time becomes the slowest call, not the sum. Dependent calls stay sequential, with the dependency named in a comment. 3) For a call that is unavoidably slow, do not let it block everything: move that section into its own component wrapped in Suspense (or rely on loading.tsx), so the fast parts stream to the user first. 4) Use what the platform gives before inventing a data-loader layer: fetch requests with the same URL are deduplicated within one render pass, and cache/revalidate options handle repeat visits. 5) If you cannot tell whether two calls are independent, check what inputs each actually needs instead of guessing. Only refactor once the dependency graph is drawn, and explain why the new shape matches the graph (what now runs in parallel and what legitimately cannot) — not just that the page feels faster once.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #500\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}