Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

Sanity deployment options for Netlify: serve bundle vs CI/CD flow explained

6 repliesLast updated: Nov 29, 2025

☆ Hi there,I beg your pardon to bother with a probably already asked question.
I just commit my sanity installation to my Gatsby Github repo linked to Netlify deploy (Gatsby installation and setting with Netlify existed previously, before to discover and add Sanity to the project) (my Sanity project has been init from scratch, no template, nothing than cli).
Now, Netlify is acting bumping on the first data from Sanity as if not knowing it at all, which is logic as I haven't done anything in particular.
This blocks the Netlify deploy.
So I searched in the docs, I found the «hosting and deployment» page, but reading at it as carefully as possible, I do not understand the difference between the two options:
1. to «serve the bundle» to Github via Noode.js
2. and next paragraph «deploying a CI/CD flow» (what those abbreviations mean?) (Command Interface and ... ??)(Change Directory??).
Difficult to make a choice not understanding anything!
Then it says «create a token», I can do it, no worries, I have done one already.
But «remember to add
user Q/cli as a devDependency», why not, but you mean at the level of the Github repo probably?Probably YES.
I'll appreciate if you could precise some element of information and the pro and cons of 1) and 2).
Thank you in advance ☆
AI Update

I can totally understand your confusion! Let me break this down into clear, practical steps for your Gatsby + Sanity + Netlify setup.

First, the good news: you don't need to choose between those two "hosting and deployment" options you're reading about. Those sections are actually about hosting Sanity Studio itself (the content editing interface), not about deploying your Gatsby site. Let me clarify what's happening:

What's Actually Going Wrong

Your Netlify build is failing because your Gatsby site needs to fetch content from Sanity during the build process, but it doesn't have the proper configuration yet. This is a common setup step that's separate from hosting decisions.

What You Need to Do

1. Install the Gatsby source plugin (if you haven't already):

npm install gatsby-source-sanity

2. Configure your gatsby-config.js to connect to Sanity:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-sanity',
      options: {
        projectId: 'your-project-id',
        dataset: 'production', // or whatever dataset you're using
        token: process.env.SANITY_TOKEN, // optional, for private datasets
        watchMode: true, // for development
      },
    },
  ],
}

3. Set up environment variables in Netlify:

About Those Confusing Terms

CI/CD means "Continuous Integration/Continuous Deployment" - it's just a fancy way of saying "automatically build and deploy when you push code to GitHub."

"Serving the bundle" refers to hosting your Sanity Studio (the content management interface where editors create content). You have two options:

For most people, I'd recommend option 2 (sanity deploy) because it's simpler - just run that command and your Studio is hosted. Your Gatsby site remains separate on Netlify.

The @sanity/cli Dependency

When the docs mention adding @sanity/cli as a devDependency, they mean in your Sanity Studio folder (where your sanity.json file lives), not your Gatsby repo. If you initialized Sanity properly, this should already be there.

Understanding Studio Hosting

As explained in this community answer about hosting Studio on Netlify, where you host your Studio doesn't affect API requests. The Studio is just a React single-page application - your Gatsby site will still make requests to Sanity's Content Lake regardless of where the Studio lives.

Pros of hosting Studio on Sanity's servers (sanity deploy):

Pros of hosting Studio on Netlify:

Quick Checklist

The Netlify technology partner page has more details about triggering rebuilds when content changes, which you'll want to set up next using deploy hooks or Sanity Functions for more advanced automation!

Show original thread
6 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

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.

Related contributions