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?

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.