React › Static Site Generation (SSG) & Hydration
What is incremental static regeneration and how does it solve the problem of static content becoming outdated?
IntermediateAnswer
Incremental static regeneration lets a statically generated page be automatically rebuilt in the background after a set amount of time, without needing to rebuild the entire site. This gives you both the speed of static pages and reasonably fresh content, without visitors ever seeing a slow, fully dynamic page.
export default async function ProductPage({ params }) {
const product = await getProduct(params.id);
return <ProductDetail product={product} />;
}
export const revalidate = 60; // rebuild this page in the background at most once every 60 secondsReal-world example A product page shows the same fast static page to most visitors, while Next.js quietly rebuilds it in the background every sixty seconds, ensuring the price and stock information never stays outdated for too long.