Understanding getStaticProps and preview mode for a Next.js Sanity site
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
. 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
prop to your return from getStaticProps (though not in `props`—it would be a sibling to