👀 See Sanity in action: Watch product demo now →

How to Compile Content in JavaScript Bundles Instead of Fetching at Runtime

2 replies
Last updated: Jun 17, 2022
Hi there, just wondering if it’s possible or if anyone can point an example of compiling content from sanity into javascript bundles rather than fetching it at runtime? Is there a process for that or is it just a case of saving an instance of the required content as a
.json
?
Jun 17, 2022, 11:26 AM
Some frameworks do that for you like Next.js. Otherwise you could write a Node.js script which uses the JS client to fetch the data you want, and you write it on disk as JSON, yes.
Jun 17, 2022, 11:37 AM
Okay, sounds like a script is the way to go then – thanks!
Jun 17, 2022, 11:47 AM

Sanity.io – build remarkable experiences at scale

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

Categorized in