Real-time updates with Sanity watch mode

Updated: Feb 17 2022

Watch mode allows you to see realtime updates without having to manually restart the build process.

Set watchMode: true in your gatsby-sanity-source plugin options, to set up a listener which watches your project for changes.

Take it further by setting overlayDrafts: true to immediately apply any changes you make to draft content.

You will then need to generate a token from the Sanity manage console.

Navigate to > settings > API > Add New Token.

Create a Read token called Gatsby and add to your gatsby-config.js.

	resolve: "gatsby-source-sanity",
	options: {
		projectId: "your_project_id",
		dataset: "your_dataset_name",
		overlayDrafts: true,
		watchMode: true,
		token: 'your_token_id'

Restart gatsby develop.

Now when you edit content in the Studio CMS you will see changes occur in Gatsby in realtime.

Monthly Newsletter

Once a month I curate a newletter for designers and developers interested in static sites, CSS and web performance. Check out past issues to get an idea.