👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

How to Deploy a Static Site Generator

3 replies
Last updated: Mar 29, 2021
Hi! I was curious what methods people use to deploy their sites with a static site generator (in my case, Next.js). I want the production site to be static, but have a non-static version to do previews. We host the production site on S3, but can likely host a preview site elsewhere, if needed.
Anyone have thoughts/examples of workflows (drafts, webhooks, etc.) that people use to control when things go to prod while also allowing for edited content to be previewed?

(also, not sure if this channel is the right place for this -- lmk and thanks!)
Mar 8, 2021, 7:45 PM
Thanks
user U
! The site I'm building is fully static -- pulls from Sanity at build time + exports all the static assets, so I don't need the serverless stuff, but I appreciate the info.
Mar 9, 2021, 8:53 PM
That makes sense -- I think what makes sense for my usecase is to host the production site statically, but have a staging instance hosted either with serverless functs or as a node server to allow for preview! Mostly writing this out since I've been looking all around this Slack for various solutions to problems, so maybe someone will stumble on this one haha
Mar 10, 2021, 4:29 PM
You met the same problem as me. React-query is being used. This is my solution.


1. Build/Deploy CI after merging into preview branch
2.
https://react-query.tanstack.com/guides/ssr react-query options
{ enabled: process.env.MODE === 'preview' ? true : false }
3. sanity client env

{
  projectId: 'some-project-id',
  dataset: 'my-dataset',
  useCdn: process.env.MODE === 'preview' ? false : true
}
Mar 29, 2021, 4:13 AM

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?