Gatsby + Sanity

The content backend Gatsby deserves

Trusted by leading digital innovators

  • Figma
  • Anthropic
  • Brex
  • Shopify
  • Linear
  • Skims
  • Unity
  • loveholiday
  • Expedia Group
  • Mejuri
  • Replit
  • Tecovas
  • PUMA
  • MoMA

Why Gatsby developers choose Sanity

Schema as code

Your content model lives in code, not in a rigid admin UI. Define document types, references, validation, and editorial structure in your Studio config, then evolve it as your Gatsby project grows.

Flexible querying

Use the official Gatsby source plugin to pull Sanity content into Gatsby’s GraphQL layer, or use @sanity/client directly when you want GROQ for custom app logic. You are not boxed into one access pattern.

Type safety

typegen can generate TypeScript definitions from your schema and GROQ queries, which makes Gatsby integrations easier to maintain as your content model changes.

Editorial customization

Fully programmable editorial UI, so you can ship content tools your team actually wants to use without maintaining a separate app.

Power anything

When your content is data, stored as JSON, you can power web, mobile, storefronts, internal tools, and agentic applications from the same backend.

Built for structured content, not page fields

Circular photo mosaic blending red images on the left with blue images on the right, on a black background.

90+ Guides, Plugins, and Templates for Sanity + Gatsby

Explore resources
White dotted 'GC' monogram in a circle on a black dotted background.
The results are in

Sanity is ranked #1 out of 85 CMSes on G2

Read G2 reviews
G2 Winter 2026 Grid chart with 'Leader' designation, showing multiple companies plotted and a large G2 logo.
CMS INTEGRATIONS

Integrate Sanity with other technologies

Sanity can be integrated with any major framework, providing the flexibility need to have full control of your project.

FAQs

Is Sanity a good CMS for Gatsby?

Yes. Sanity works well as a headless CMS for Gatsby because it gives you structured content, a customizable editing environment, and multiple ways to query content. You can use the official Gatsby source plugin to pull Sanity content into Gatsby's GraphQL data layer, or use @sanity/client directly when you want to query with GROQ.

How do you connect Gatsby to Sanity?

Most teams connect Gatsby to Sanity with the official Gatsby source plugin. It pulls content from Sanity into Gatsby so you can query it during builds using Gatsby GraphQL. If you need more control, you can also connect directly with @sanity/client and fetch content from Sanity outside Gatsby's source layer.

Can Gatsby use Sanity with GraphQL?

Yes. Gatsby can use Sanity content through the official Gatsby source plugin, which makes that content available in Gatsby's GraphQL layer. Sanity also supports deploying its own GraphQL API from your schema if you want a Sanity-hosted GraphQL endpoint.

Can I use GROQ with Gatsby?

Yes. Gatsby developers often use the source plugin for build-time GraphQL queries, but Sanity also supports querying content directly with GROQ through @sanity/client. That is useful when you want more flexible query logic or need to fetch exactly the shape of data your app needs.

Does Sanity support typed content for Gatsby projects?

Yes, with some nuance. Sanity TypeGen can generate TypeScript definitions from your schema and GROQ queries, which helps when you want stronger typing in your Gatsby integration. Sanity currently documents TypeGen as an experimental feature, so teams using GraphQL heavily may still prefer established GraphQL typing tools in that part of the stack.

Is Sanity only for Gatsby websites?

No. You can use Sanity as the CMS for a Gatsby site, then reuse the same structured content across other frontends, apps, and services later. That means Gatsby does not have to be a dead end. The same content model can support your website today and other channels as your stack grows. You can see more in the JavaScript client documentation.

Does Sanity support a GraphQL API as well as GROQ?

Yes. Sanity's primary query language is GROQ, but it also supports deployed GraphQL APIs generated from your schema. Sanity's docs are clear that GROQ is the main querying model, while GraphQL is available for teams that want that API shape or ecosystem tooling.

Why use Sanity instead of a traditional CMS for Gatsby?

Traditional CMSes often force content into page-shaped fields and rigid editorial workflows. Sanity gives Gatsby teams structured content, schema as code, and a customizable Studio so developers can model content around the product they are building, not around CMS limitations. That makes it easier to reuse content, scale the model over time, and support more than one frontend from the same backend. For a deeper look at how Sanity works as a developer platform, see the JavaScript client docs and GraphQL docs.

Less talk, more code

Get started