ISR with Dynamic Routes
You'll learn how to combine Incremental Static Regeneration with dynamic path segments to efficiently pre-render popular pages while generating others on-demand.
The Challenge of Scale
When you have thousands (or millions) of dynamic routes—like product pages, blog posts, or user profiles—pre-rendering everything at build time becomes impractical. ISR with dynamic routes lets you choose which pages to pre-generate and which to create on the first request.
Pre-rendering Strategy
You control this through getStaticPaths with the fallback option. Your strategy typically includes:
- Pre-render popular paths: Generate your top 100 products, most-read articles, or featured content at build time
- On-demand for the rest: Let less-visited pages generate when first requested, then serve them statically afterward
- Revalidate both: Apply your revalidation interval to all pages, whether pre-rendered or generated on-demand
The Three-Tier Approach
Think of it like a restaurant with three kitchen strategies:
- Pre-made meals (pre-rendered): Popular dishes ready immediately
- Cook on order (fallback): Less common dishes made when requested, then kept warm
- Refresh periodically (revalidation): Update all meals regularly to keep them fresh
With fallback: 'blocking', users wait for new pages to generate (like ordering fresh). With fallback: true, you show a loading state while the page generates in the background.
This approach scales beautifully—you get fast builds, instant loading for common pages, and automatic generation for the long tail of content.
Key Takeaway: ISR with dynamic routes balances build performance and runtime flexibility by letting you pre-render strategic paths while generating and caching others on-demand, all with automatic revalidation to keep content fresh.