Performance: Why rendering strategy matters
Rendering strategy affects how fast the main content appears and how quickly users can interact with the page.
Jump into concepts and practice - no test required
export async function getStaticProps() { const data = await fetch('https://api.example.com/data').then(res => res.json()); return { props: { data } }; } export default function Page({ data }) { return <div>{data.title}</div>; }
export default async function Page() { const data = await fetch('https://api.example.com/data').then(res => res.json()); return <div>{data.title}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side data fetching | Many (delayed DOM update) | Multiple (due to late content injection) | High (delayed paint) | [X] Bad |
| Server-side or static rendering | Few (immediate DOM ready) | Single (initial layout) | Low (fast paint) | [OK] Good |
getStaticProps to fetch data at build time.getStaticProps triggers SSG; others are for server-side or legacy methods.export async function getServerSideProps() {
return { props: { time: new Date().toISOString() } };
}
export default function Page({ time }) {
return Current time: {time};
}export async function getStaticProps() {
const data = await fetch('https://api.example.com/data').then(res => res.json());
return { props: { data } };
}
export default function Page({ data }) {
return {data.message};
}revalidate enables Incremental Static Regeneration, refreshing data after set seconds.revalidate: 10 updates the page every 10 seconds without slowing initial load, unlike server-side rendering which runs every request.