ndimatteo / HULL

💀 Headless Shopify Starter – powered by Next.js + Sanity.io
https://hull.dev
MIT License
1.36k stars 167 forks source link

Is it true that you have to redeploy every time a product is added? #120

Closed robksawyer closed 9 months ago

robksawyer commented 1 year ago

I've recently set this up because it looks rad! Nice work on everything. I'm trying to get used to the workflow and wanted to confirm that I do in fact need to deploy via Sanity (and have the app rebuild on Vercel) before new products appear. It's not enough to just add them to Sanity Studio?

My current process (which isn't great and is time consuming):

robksawyer commented 1 year ago

It's been months since I've had to add a product and now when I go to deploy, I am getting the following error on Vercel. Can someone remind me where I should start debugging this?

TypeError: Cannot destructure property 'options' of 'activeVariant' as it is undefined.

benitodotcool commented 1 year ago

Hey @robksawyer, As explain inside the README.md:

Client Updates

Once you hand off to the client you'll want to give them the ability to generate builds when they make updates within the Sanity Studio. The easiest way to do this is through my Vercel Deploy plugin.

I'm not currently using this template, but it seems that @ndimatteo also developed a Sanity plugin that allows this.

Here is what I understand:

  1. The website uses Static Generation to be fast.
  2. The website uses something to get live product's quantity, so static pages shows the ‘Add to cart’ or ‘Sold out’ button.
  3. So if you don't trigger the deploy on Vercel, it's normal that you don't have any difference.

I can missunderstand something here, but I think it's the way this template works.

I hope it helps you.

All the best,

Benito

Dujota commented 1 year ago

you will need to trigger a bulld through the vercel serverless functions in order to revalidate the static pages, alternatively you can use the isg feature of next js to rebuild pages after some time. (basically cache page build for a certain amount of time and the bust cache, force a particular page to re-generate)

on many sanity projects I have done for clients the revalidate option has worked great, content editor makes a change and publishes, then the page will udpate when the validate timer expires for a given client, once they leave the page and come back or reload the page,

ndimatteo commented 9 months ago

hey there @robksawyer – I'm just doing some issue maintenance here. Going to close this one, but to reiterate what @Dujota mentioned already:

  1. Yes, by default, you will need to rebuild your site when new products are added in Shopify, or any changes are made in Sanity. This is the standard flow for Static Site Generation (SSG).
  2. You can automate this by using ISR, or page-level revalidation if you wish