
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGreat question! You're on the right track thinking about gatsby-source-sanity as your main integration point. Let me break down your options and clarify the GROQ vs GraphQL situation with Gatsby.
The gatsby-source-sanity plugin is indeed the standard way to connect your existing Gatsby project to your existing Sanity project. You're right to focus on its README - it gives you a clean, minimal setup without all the extra starter template code.
Here's the key thing to understand: gatsby-source-sanity fetches data from Sanity and transforms it into Gatsby's GraphQL layer. The plugin makes only two API requests during the entire build process - it first fetches the GraphQL Schema Definitions from Sanity's deployed GraphQL API, then streams all accessible documents using the project's export endpoint.
So the flow is:
This is actually efficient - you get to query with GraphQL in your Gatsby components (which is the standard Gatsby pattern), and the plugin handles the Sanity integration efficiently.
Yes! You have two options:
Option 1: Use gatsby-source-sanity (recommended for most cases)
watchMode for development hot-reloadingoverlayDrafts for preview functionality_raw fields for Portable Text dataOption 2: Use @sanity/client directly with GROQ
client.fetchgatsby-source-sanityExample of using the client directly:
import sanityClient from '@sanity/client'
const client = sanityClient({
projectId: 'your-project-id',
dataset: 'production',
apiVersion: '2023-05-03',
useCdn: true
})
// In a Gatsby page or during build
const data = await client.fetch(`*[_type == "post"]{title, slug}`)Both GROQ and GraphQL are query interfaces to the same underlying Content Lake, so the performance difference at build time is minimal. GROQ is Sanity's native query language and is more expressive for certain content transformations and projections, but for Gatsby builds, the efficiency comes from how gatsby-source-sanity fetches data (just two API requests total), not which query language you use.
The real advantage of GROQ is its expressiveness and the fact that it's designed specifically for Sanity's content structure. But when using gatsby-source-sanity, you're querying Gatsby's GraphQL layer (which is already optimized), not Sanity directly during component renders.
The gatsby-source-sanity plugin gives you:
watchMode: true: Sets up a listener that pushes changes from Sanity to Gatsby in real-time without additional API queries during developmentoverlayDrafts: true: Preview draft content in development while only showing published content in production (requires a read token)_raw fields: Special fields for accessing raw Portable Text data with reference resolutionYou're not missing anything by using just this plugin - it's the recommended approach and includes all the integration features you need.
gatsby-source-sanity following its READMEsanity graphql deploywatchMode: true in development for live updatesoverlayDrafts: true with a read token for draft previews@sanity/client with GROQ if you need client-side queries or custom build-time logic that doesn't fit the source plugin patternThis gives you a clean, minimal setup between your existing projects while maintaining all the powerful features. You'll understand exactly what's happening without the extra template code you don't need.
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