2
export async function getStaticPaths() { 
 // Call an external API endpoint to get posts
 const res = await fetch('https://.../posts')
 const posts = await res.json()

 // Get the paths we want to pre-render based on posts
 const paths = posts.map((post) => `/posts/${post.id}`)

 // We'll pre-render only these paths at build time.
 // { fallback: false } means other routes should 404.
 return { paths, fallback: false }
}

I'm curious about this thing; in Next.JS docs, pre-render would fetch all posts and map it to find data based on the id.

When posts total more than a million posts, is that impact the performance?

Danar Widi
  • 21
  • 2
  • 3
  • i asked my self the same question. what happen if getStaticPaths should query millions id, database will crash when loading id in one shoot ?? – AlainIb Jun 29 '21 at 09:31
  • Have a look at [this discusion](https://github.com/vercel/next.js/discussions/27574) – francis Aug 13 '21 at 20:56

0 Answers0