Performance: Static rendering (default)
Static rendering impacts the initial page load speed by pre-building HTML at build time, reducing server work and speeding up content delivery.
Jump into concepts and practice - no test required
export async function getStaticProps() { const res = await fetch('https://api.example.com/data'); const data = await res.json(); return { props: { data } }; } export default function Page({ data }) { return <div>{data.title}</div>; }
export async function getServerSideProps() { const res = await fetch('https://api.example.com/data'); const data = await res.json(); return { props: { data } }; } export default function Page({ data }) { return <div>{data.title}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Server-side rendering on each request | High (dynamic DOM) | Multiple per request | High due to delayed HTML | [X] Bad |
| Static rendering at build time | Low (static DOM) | None at runtime | Low, instant paint | [OK] Good |
export default function Page() {
return <h1>Welcome to Next.js!</h1>
}export default function Page() {
const data = fetch('https://api.example.com/data')
return <div>{data.title}</div>
}