๐Ÿ˜Ž Discover cool tips and tricks for customization in our next Developer Deep Dive virtual event - sign up now!

Understanding getStaticProps and preview mode for a Next.js Sanity site

3 replies
Last updated: Jun 4, 2023
Could someone help me out with understanding getStaticProps and preview mode for a next.js sanity site? Both ends are deployed, I have a revalidate timer on getStaticProps, the only time new content comes up is when I redeploy. From what I'm reading I need to i @sanity/production-preview and have a preview file in both front and back to send and receive the url? Need to create a sanity.json file which I don't have one and I am unsure of what to fill it with. A helper function to get the client on preview mode for getStaticProps. A button function for the sanity studio so I could see the preview as well, is it necessary? Is that how I can have "ISR" I think and getStaticProps, have the content be loaded on the site with delay instead of having to redeploy everytime. Or would it be better that I use getServerSideProps? Wouldn't that be less optimized? Excuse the wall of text, or the dumb questions, I am trying to wrap my head around it.
May 31, 2023, 11:19 PM
Hi
user E
. Not dumb questions at all. This guide covers setting up Live Preview with Next.js, getStaticProps, and Sanity. From there, I believe you can add the
revalidate
prop to your return from getStaticProps (though not in `props`โ€”it would be a sibling to
props
) to configure ISR .
May 31, 2023, 11:37 PM
Very sorry for the late reply
user A
I read the documents several days ago and it worked well. Thank you for the help, highly and heavily appreciated.
Jun 4, 2023, 7:20 PM
Not to worry! Glad that worked for you. ๐Ÿ™Œ
Jun 4, 2023, 7:20 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?