ISR Test #6

This test supports a hyopthetical number of dynamic paths. The path param is id, and we're supporting IDs 1 - 5. IDs 1 - 5 will be returned from getStaticPaths. We've set fallback: 'blocking' in getStaticPaths, meaning that any other id should build on demand. This time though, the page will wait for getStaticProps to run and generate the HTML before serving up the page. This is identical to SSR. Future requests will be cached.

Code

export async function getStaticPaths() {
  return {
    paths: [
      {
        params: { id: '1' }
      },
      {
        params: { id: '2' }
      },
      {
        params: { id: '3' }
      },
      {
        params: { id: '4' }
      },
      {
        params: { id: '5' }
      }
    ],
    fallback: 'blocking',
  };
}

export async function getStaticProps(context) {
  const id = context.params.id;

  return {
    props: {
      id,
    },
    revalidate: 2,
  };
}

Local production build:

Vercel deployments: