Statically generate dynamic routes in Next.js with `getStaticPaths` and `getStaticProps`

InstructorXiaoru Li

Share this video with your friends

Send Tweet

The companion life-cycle method getStaticPaths of getStaticProps lets us use the data we have at build-time to specify which dynamic routes (like /pages/blog/[slug]) we want to generate statically.

In this lesson, we will learn how these two functions can be used in conjunction with each other to fetch mock blog data from the file system, then generate static HTML files for each blog post route. By the end of this lesson, you will be able to fully utilize the powerful Static Site Generation (SSG) feature of Next.js to build and optimize your next project.