Mukhtar Bahadory

How does getStaticPaths work?

getStaticPaths is a core function for utilizing Next.js to statically generate your assets.

It essentially comes into play when you define a route that can potentially be dynamic.

What's interesting here though is that with getStaticPaths and getStaticProps, you don't have access to the client's requested absolute route, at least in the most simplest case.

Thus, every single possibility for the respective dynamic route must be discovered and provided to the paths property returned from getStaticPaths.

For example, if you have solely the dynamic route [fruit].js under your pages directory, then every single fruit that you wish for the client to be able to discover must be discovered and exposed.

The fallback property of getStaticPaths is able to modify this behavior. TODO

In this post, only the most simplest case is discussed.