From the course: Learning Next.js

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Discovering the rendering strategies with getStaticPaths

Discovering the rendering strategies with getStaticPaths

From the course: Learning Next.js

Discovering the rendering strategies with getStaticPaths

- [Instructor] With Next.js, there is another use case which is getStaticPath. So this function getStaticPath works just like getStaticProps. It runs at build time, and it is used to generate path and pre-render the content at build time. And it returns an object, paths, right here with an array as a value, which is used to render the predefined path. So when do we need to use getStaticPath? So this is used to statically generate a list of path at build time during the next build process. And you use getStaticPath when you know that you're going to need only static content. So no change, no input from the user is required. And when you need to generate path in advance. So we're going to use the same example of the news article for this demo with getStaticPath. We're just going to look at the source code that I am providing, to start this demo. So we're going to have the same text inputs. And also for the…

Contents