Performance: Interleaving server and client
HIGH IMPACT
This affects how quickly the user sees meaningful content and how responsive the page feels during loading.
export default async function Page() { const data = await fetchDataAsync(); return ( <> <ServerComponent data={data} /> <ClientComponent /> </> ); } function ServerComponent({ data }) { return <div>{data}</div>; } 'use client'; function ClientComponent() { const [state, setState] = React.useState(null); React.useEffect(() => { setState('Client loaded'); }, []); return <div>{state}</div>; }
export default function Page() { const data = fetchDataSync(); return <ClientComponent data={data} />; } function ClientComponent({ data }) { const [state, setState] = React.useState(null); React.useEffect(() => { setState(data); }, [data]); return <div>{state}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous data fetch blocking server render | Low initial DOM nodes | Single large reflow after data fetch | High paint cost due to delayed content | [X] Bad |
| Interleaved server streaming with client hydration | More DOM nodes progressively added | Multiple small reflows during hydration | Lower paint cost with faster content display | [OK] Good |