I made a step-by-step tutorial on YouTube HERE
Or follow the steps below:
- Clone this repository
cd sanity
npm install -g @sanity/cli
sanity init
and follow the prompts (you will need to create a Sanity account if you haven't already)npm run graphql-deploy
cd ..
to navigate back to the root foldernpm install
in the project's root foldernpm run dev
to start the studio and frontend locally- Your studio should be running on http://localhost:3333
- Your frontend should be running on http://localhost:8000
- Open http://localhost:3333 and copy the project ID from the Project info section
- Navigate to the client-config.js file in the gatsby directory
- Replace the project ID with your Project ID
npm run build
to build to production locally
- Go to your project’s API settings on manage.sanity.io and create a token with read rights.
- Rename
.env.development.template
to.env.development
and paste in the token:SANITY_READ_TOKEN="yourTokenHere"
. - Restart the development server (
ctrl + C
andnpm run dev
).
If you want to turn off preview you can set watchMode: false
in gatsby-config.js. If you just want to preview published changes you can set overlayDrafts: false
in gatsby-config.js.
Join Sanity’s developer community or ping us on twitter.