0

The Sitecore docs on deploying JSS Next.JS sites to Vercel state that you must trigger a next build and site deployment via webhook on publish in order to pre-render the site with static site generation (SSG):

Triggering Webhooks when publishing content: when prerendering the application with static generation or deploying static HTML with next export, you must trigger a next build and site deployment on publishing new content. To facilitate this, Sitecore Headless Services and Sitecore Experience Edge for XM can invoke a webhooks. You can leverage Sitecore webhooks with Vercel deploy hooks.

It seems excessive to constantly be running builds and deployments whenever content is published. It creates noise and can result in excess serverless function executions (SFE). Vercel recommends incremental static generation (ISR) and on demand revalidation, instead of full builds for webhook events which are constantly happening.

Another docs page seems to indicate that the static pages can be updated after having already built, so there doesn't appear to be any limitations about how to configure the site:

When statically generating JSS Next.js pages, you can update static pages after you have already built the application for production by using incremental static regeneration. To use ISR, you define the revalidate property in the GetStaticProps implementation for that page.

Are the publish webhooks and constant builds / deploys necessary? Or are they just a starting point, after which we add ISR where needed in order to reduce or completely eliminate the constant builds and deploys?

2
  • You only need to trigger a deploy if you are using next export. If you are Deploying your site to Vercel you should not be triggering rebuilds like this.
    – Richard Seal
    Aug 8, 2023 at 2:39
  • @RichardSeal AFAICT, next export is not being used. But that's the crux of it. The docs say, "When prerendering the application with static generation or deploying static HTML with next export, you must trigger a next build and site deployment on publishing new content" Aug 8, 2023 at 14:40

1 Answer 1

1

Triggering Webhooks when publishing content: when prerendering the application with static generation or deploying static HTML with next export, you must trigger a next build and site deployment on publishing new content. To facilitate this, Sitecore Headless Services and Sitecore Experience Edge for XM can invoke a webhooks. You can leverage Sitecore webhooks with Vercel deploy hooks.

This documentation is misleading. It very much depends on how you are hosting your application:

Pure Static Hosting:

If you are hosting your site entirely statically, on a CDN for example, and you are deploying your site using next export, then yes, for a content change to be visible on your site, you must re-export your next application using next export again. Whether you do this on every content change or have a scheduled approach, say every 2 hours we redeploy, that is up to the project's requirements.

Hybrid Hosting (Vercel, Netlify, ASWA Hybrid Mode etc...)

If you are hosting on a more recommended approach, like Vercel, that do a hybrid host - a combination of statically generated pages plus the addition of middleware, serverless functions and regeneration, you do not need to redeploy your app to see content changes. You can use ISR (Incremental Static Regeneration) or On Demand Revalidation in you application to see the updated content. Both of these are a better option than re-deploying the application.

There are considerations for both tho. With ISR you will need to tune your revalidation period to find a balance between using up all your serverless function executions and how quick the client wants content to be visible on the site after a publish.

On Demand Revalidation can take care of that, but you will need to implement the revalidation functions called by the Experience Edge web hooks and make sure that you don't overload your executions that way.

Its all a balancing act based on how fast you want everything vs how much you want to pay for that speed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.