Static Site Generation (SSG) in Next.js
Static Site Generation builds pages at build time — before any user visits the website.
What is SSG?
SSG pre-renders pages into static HTML during deployment. These files are served instantly when users request them.
How does it work?
export default async function Page() {
const data = await fetch("API", { cache: "force-cache" });
return <div>{data.title}</div>;
}The page is generated once during build and reused for every visitor.
Why use SSG?
- Extremely fast loading
- SEO friendly
- Low server cost
- Great scalability
Real-World Example
Blog posts, documentation pages, and landing pages that rarely change are perfect candidates for SSG.
Interview Tip
SSG generates pages at build time and serves static HTML for maximum performance and SEO.
- sunt aut facere repellat provident occaecati excepturi optio reprehenderit
- qui est esse
- ea molestias quasi exercitationem repellat qui ipsa sit aut