Question from the Next.js test

How to use Incremental Static Regeneration (ISR) in Next.js to update blog posts periodically after their initial publication.

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 425 times
Edit
4
Community EvaluationsNo one has reviewed this question yet, be the first!