Next.js & App Router (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is Incremental Static Regeneration (ISR) and how does `revalidate` work?
junior LevelCode ExampleApache Kafka
In Simple Words: Historically, SSG required rebuilding the entire website whenever content changed in a CMS. ISR allows you to update static pages in the background without rebuilding the whole site:
typescript
// Revalidates this page at most once every 60 seconds
export const revalidate = 60;
export default async function ProductPage() {
const product = await db.products.findFirst();
return <h1>{product.name}</h1>;
}
- Lifecycle:
- Requests within 60 seconds receive the cached static HTML instantly.
- The first request after 60 seconds still receives the cached page (stale), while Next.js triggers a background re-render.
- Once regenerated successfully, Next.js replaces the cache. Subsequent users get the fresh HTML.