Q6: How does Incremental Static Regeneration (ISR) work in the Pages Router?
ISR allows static pages to be updated in the background without re-building the entire site. By adding a revalidate property (in seconds) to getStaticProps, Next.js regenerates the page in the background when requests come in after the timer expires.
ISR Configuration in getStaticProps
export async function getStaticProps() {
const data = await fetchData();
return {
props: { data },
revalidate: 60, // Next.js will attempt revalidation every 60 seconds
};
}💡 Setting revalidate: 60 ensures static HTML updates in the background when requested after 60 seconds.
Key Takeaways
- Enable by returning
revalidate: <seconds>ingetStaticProps. - Combines static page performance with periodic dynamic updates.
Knowledge Check
What happens when a user requests an ISR page 120 seconds after build time if revalidate is set to 60?