Performance: Server component restrictions
HIGH IMPACT
This affects the initial page load speed and server response time by limiting what code runs on the server versus the client.
export default async function Page() { const res = await fetch('https://example.com/api/data'); const data = await res.json(); return <div>{data.message}</div>; }
import React from 'react'; export default function Page() { const [data, setData] = React.useState(null); React.useEffect(() => { fetch('/api/data').then(res => res.json()).then(setData); }, []); if (!data) return <p>Loading...</p>; return <div>{data.message}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client data fetching in component | Many (due to hydration) | Multiple (due to delayed content) | High (JS parsing and execution) | [X] Bad |
| Server component with data fetching | Minimal (static HTML) | Single (initial paint) | Low (HTML only) | [OK] Good |