ISR is a powerful feature of Next.js that allows static pages to be updated without requiring a full rebuild. This is ideal for blogs, e-commerce sites, and other dynamic applications that need fresh content while maintaining fast performance.
Using ISR
export async function getStaticProps() {
const res = await fetch("https://api.example.com/posts");
const data = await res.json();
return {
props: { posts: data },
revalidate: 10, // Regenerates every 10 seconds
};
}
- Faster builds compared to full static generation.
- Ensures fresh content without the overhead of server-side rendering.
Conclusion
ISR offers the best of both worlds—speed and flexibility—making it an essential tool for delivering real-time yet performant applications.