
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! The good news is you don't need to worry about making hundreds or thousands of API calls with the Gatsby + Sanity setup. Gatsby is indeed "smarter" than that, and here's how it actually works:
The gatsby-source-sanity plugin only makes two API requests during the entire build process, regardless of how many GraphQL queries you have in your components. Here's what happens:
This data is then loaded into Gatsby's local GraphQL data layer (an in-memory datastore). All your page queries, static queries, and component queries are executed against this local data layer at build time—not against Sanity's API.
You don't need to fetch everything at the top and pass it down through props. In fact, that's not the Gatsby way! Instead:
useStaticQuery or StaticQuery in your regular components for component-specific dataThe only limitation is that useStaticQuery and StaticQuery cannot accept variables—they must be static queries. If you need variables (like getting data based on a page slug), use page queries instead.
For the Gatsby + Sanity + Netlify stack:
useStaticQuery for static component data (like site metadata, navigation, etc.)watchMode: true in development for real-time content updates without rebuildingThe plugin architecture is specifically designed to be efficient, so embrace Gatsby's data layer rather than trying to work around it!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store