{"success":true,"name":"stream-slow-sections-with-suspense-and-loading-tsx-in-next-j","description":"A Next.js page waits on slow data and shows nothing meanwhile","category":"ai-brimind","path":"ai-brimind/stream-slow-sections-with-suspense-and-loading-tsx-in-next-j/SKILL.md","file":"SKILL.md","content":"---\nname: stream-slow-sections-with-suspense-and-loading-tsx-in-next-j\ndescription: \"A Next.js page waits on slow data and shows nothing meanwhile\"\n---\n\n# Stream Slow Sections With Suspense and loading.tsx in Next.js\n\n## When to use\nProject is Next.js App Router, and a page feels blank or frozen while server data loads, and a spinner-everywhere rewrite feels tempting.\n\n## Example request\nwhole page blank until the slowest query finishes → add loading.tsx for the route, or wrap just the slow section in Suspense so the shell appears instantly. — Streaming beats blocking. | converting the page to client-side fetching to 'show something faster' → that trades one blank screen for spinners plus a bigger bundle; streaming keeps server rendering AND instant shell. — Wrong trade. | one Suspense boundary around the entire page → everything still waits for everything; boundaries work per-section. — Boundary granularity. | layout jumps wildly when real content replaces the fallback → the fallback skeleton should reserve roughly the same space. — Honest placeholders.\n\n## Instructions\nAct like a UX-minded engineer who never lets one slow query hold the whole page hostage. When a Next.js route feels slow or blank: 1) Identify WHICH data is slow — not 'the page is slow' but 'the stats query takes 2s while the rest is instant'. Measure or log per-fetch before restructuring anything. 2) Use the built-in streaming tools at the right granularity: loading.tsx gives the whole route an instant loading state; a <Suspense> boundary around just the slow component lets the fast 90% of the page render immediately while the slow part streams in when ready. Move the slow await INTO the wrapped component so the boundary can actually do its job. 3) Do not solve this by switching to client-side fetching — that abandons server rendering to gain a spinner. Streaming gives the fast shell without that trade. 4) Make fallbacks honest: skeletons shaped like the real content, reserving similar space, so nothing jumps when data arrives. 5) If several sections are slow, check first whether they are a sequential waterfall (fix the awaits) before adding boundaries around symptoms. Only add boundaries once the slow piece is named and measured, and explain why the boundary sits exactly there (what renders instantly, what streams) — not just that a spinner now appears.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #503\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}