Course contentsShow
← React
Lesson 52 of 2,3962. Setup and Modern ToolingFree lesson

Gatsby: Static Site Generation

When Gatsby fits: content-heavy sites, GraphQL data layer, and plugin ecosystem for static builds.

Gatsby: Static Site Generation

You'll learn when Gatsby excels and what makes it different from runtime-rendered React apps.

What Is Gatsby?

Gatsby is a static site generator built on React. Instead of rendering pages when users request them (like traditional React apps), Gatsby builds all your HTML pages at build time. When someone visits your site, they receive pre-generated HTML immediately—no JavaScript execution needed for the initial content.

Think of it like preparing all your meals for the week on Sunday versus cooking each meal when you're hungry. Gatsby does the heavy lifting once, and users get instant results.

When Gatsby Shines

Gatsby is ideal for content-heavy sites where the content doesn't change on every visit:

  • Blogs and documentation sites
  • Marketing pages and portfolios
  • Product catalogs with relatively stable inventory

If your data changes constantly (like a social media feed), Gatsby's build-every-time approach becomes cumbersome.

The GraphQL Data Layer

Unlike the tools you've seen so far, Gatsby uses GraphQL as its data layer. At build time, Gatsby pulls content from anywhere—Markdown files, CMSs, APIs, databases—and lets you query it with GraphQL. This unified interface means you write the same query syntax whether your content comes from files or external services.

Plugin Ecosystem

Gatsby's plugin ecosystem handles common static site needs: image optimization, SEO metadata, analytics, and CMS integrations. These plugins run during the build process, transforming and optimizing your content before deployment.

Key Takeaway: Gatsby pre-builds React pages into static HTML at build time, making it perfect for content-heavy sites that need speed and SEO, powered by a GraphQL data layer and rich plugin ecosystem.