Search code examples
javascriptcontent-management-systemgatsbynetlifysanity

Gatsby not watching sanity for new published changes


I have a Gatsby site deployed to netlify. In development mode I set the option watchMode:true of gatsby-source-sanity in gatsby-config.js and this works fine to watch sanity studio for changes but in production it does not. I have tried adding a token and toggling the watchMode between true and false. The only way I see changes in production is to re build my site on Netlify


Solution

  • watchMode is only relevant when developing. Netlify hosts a static build from Gatsby, so the only way to get new Sanity content in production it to rebuild (or fetch content on the client, but probably not what you want in this case).

    You can create a webhook that will fire when content is updated in Sanity that can trigger a new build in Netlify. Example from Sanity docs.