What is Static Site Generation?
You'll learn: How SSG pre-renders pages to static HTML at build time for instant delivery and optimal performance.
The Core Idea
Static Site Generation (SSG) means generating all your website's HTML pages before anyone visits them—during a build process on your own machine or build server. Unlike SSR which renders pages on-the-fly when users request them, or CSR which renders in the browser, SSG creates a folder full of ready-to-serve HTML files ahead of time.
Think of it like meal prep versus cooking to order. SSR is like a restaurant kitchen making each dish when ordered. SSG is like preparing all meals on Sunday, refrigerating them, and just reheating when needed—nearly instant delivery with minimal effort.
How SSG Works
During your build step (often npm run build), the SSG tool:
- Fetches all necessary data (from APIs, databases, markdown files)
- Runs through every route/page in your application
- Renders each to a complete, standalone HTML file
- Outputs a directory of static files ready to deploy
These files can be served from a basic file server or CDN—no server-side logic needed at delivery time.
The Performance Sweet Spot
Since pages are pre-built, SSG delivers:
- Instant TTFB: The file already exists, no computation required
- Excellent FCP and LCP: HTML arrives complete, no waiting for JavaScript
- Maximum cacheability: Static files cache perfectly on CDNs
- Minimal server load: You're just serving files, not running application code
The trade-off? Data is frozen at build time—if your content changes, you must rebuild and redeploy.
Key Takeaway: SSG pre-renders every page to static HTML during build time, delivering instant, CDN-friendly pages perfect for content that doesn't change constantly.