👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Using CDN in development with Sanity and Next.js

7 replies
Last updated: May 31, 2023
Would like to ask for advice. Fetching the Sanity data while developing fetches the data every time i make a change.
Is there something like caching from Sanity, or maybe using cdn from Sanity when developing?

I am on a Next js project how about caching?

Any links, tips, advices would be great.
May 31, 2023, 6:44 PM
You can configure the client to use the API CDN any time—including in development. Adding
useCdn: true
should be enough for that instance of the client to always source from the API CDN.
May 31, 2023, 6:55 PM
Any down sides using cdn in dev or production? Thanks in advance
May 31, 2023, 6:56 PM
Your changes won’t show up immediately, will need time to propagate?
May 31, 2023, 6:57 PM
(changes to your data)
May 31, 2023, 6:57 PM
I will use it in production thanks! Does revalidate in next js work with useCdn set to true?
May 31, 2023, 6:58 PM
Yes it would—but as mentioned, against potentially stale data.
May 31, 2023, 7:00 PM
Great thank you!
May 31, 2023, 7:00 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?