🎤 Builder Talk: The Story Behind Lady Gaga’s Digital Experience – Register now

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?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
Hey all - what’s the quickest way to batch delete all documents of a certain type? It looks like the `sanity` cli tool allows...Jan 29, 2021
How to turn PortableText into plain text in Javascript?Dec 7, 2020
Deploying Next JS on VercelJan 20, 2021
In the tutorial, there is samples of what the API returns as JSON. Is there a way to view these ?Jan 11, 2021
DOMParser is not defined at defaultParseHtmlDec 3, 2020
Next.js and Vercel - Error! No Output Directory named "dist" foundAug 8, 2022
Warning: Data for Page Exceeds the Threshold of 128 kBAug 17, 2022
Custom Document Views - Is it Even Possible to Use the Structure Builder?Apr 21, 2022
How to get the number of nested/children components in a GROQ query.Jan 19, 2024
Issue with fetching data from an array of references and non-references in a groq query.Dec 14, 2023

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddle’s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddle’s content offering.

Nightjar
Go to The Swaddle