Medium
You are developing a blog using Next.js with the Page Router technology and wish to leverage Incremental Static Regeneration (ISR) for your blog posts. Each article is statically generated at the time of the build, but you want them to update periodically after their initial publication to ensure fast loading speeds and fresh data. Here is a code snippet from the article page :
// pages/posts/[postId].js
export async function getStaticProps({ params }) {
const postData = await getPostData(params.postId);
return {
props: {
postData,
},
revalidate: 10 // time in seconds
};
}
export async function getStaticPaths() {
const paths = getAllPostIds();
return {
paths,
fallback: 'blocking'
};
}
// ...
Author: AnasStatus: PublishedQuestion passed 300 times
Edit
2
Community EvaluationsNo one has reviewed this question yet, be the first!
Similar QuestionsMore questions about Next JS
6
Load blog post data at build time for a static render.4
What is the path to the about page in Next.js?2
What are the benefits of using dynamic imports in Next.js?2
How to manipulate HTTP response headers within a `getServerSideProps` function in Next.js1
Where to place static files in a Next.js project.