What Is On-demand ISR?

Jordan McRae


2 min

Article Banner

What is On-demand ISR?

The Vercel team recently announced a long-anticipated Next.js feature called on-demand ISR (Incremental Static Regeneration). This is a massive leap forward for Next.js, and will provide even more flexibility for developers to control when their static pages are revalidated. This is an extremely important feature for applications such as blogs, news websites, or any digital product that has data changing frequently. If you haven't had a chance to learn about what Incremental Static Regeneration is, please check out our article on Blazing Fast Apps with ISR.

Before the release of this feature, we had to define a revalidate field in our getStaticProps method. This would tell Next.js to check if any data on the page has changed after a certain amount of time in seconds. This was not a great solution for a few reasons:

  1. This revalidation check would only happen when a page was requested by a user.
  2. If data has changed somewhere (such as in a CMS) and the page needed to be regenerated, the first user who requested this page would still see the old one. They only acted as a "trigger" to regenerate the page. After the page was finally regenerated, then subsequent users would begin to see the updated page.
  3. This check would run on page requests after the revalidate timer is up, even if data hasn't changed. This is inefficient for applications with thousands of pages and can result in a tremendous amount of lost computing time.

Now, with Next.js’s version 12.2.0 update, we can use on-demand ISR to fix the issues above.

To learn how to integrate this into your Next app, see our article about on demand ISR with Next.js and Sanity.