Next.js Discord

Discord Forum

Issue using getStaticProps

Unanswered
Lilac posted this in #help-forum
Open in Discord
LilacOP
I'm using getStaticProps to create 2000+ pages, however I'm running in to an issue. The issue being that in order to create these pages, I will need to make 2000+ API requests (one request per page). Is there no way to generate dynamic pages without having to use getStaticProps and getStaticPaths in a dynamic route?

The external API route throttles the request and around 10 of the 2000 pages don't get built because of the throttling, which is also a problem.

Ideally I'd like to do one API call and map over the data and provide it to the page (or eaech individual page/route rather).

4 Replies

@joulev you probably should generate paths on demand instead and only prebuild like n (< 2000) most important routes <https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-paths#generating-paths-on-demand>
Cape lion
I have a doubt about it, if I may add this here. Maybe friend's problem is the same of me. Without generating all the pages with getStaticPaths the navigation to the first path not generated at build time needs something around 2~3s before redirect. Is it possible to reduce or not have this delay before redirect? Ps: the data are getting at client side
@Cape lion I have a doubt about it, if I may add this here. Maybe friend's problem is the same of me. Without generating all the pages with getStaticPaths the navigation to the first path not generated at build time needs something around 2~3s before redirect. Is it possible to reduce or not have this delay before redirect? Ps: the data are getting at client side
You will need to suffer from that delay once, either at build time or at runtime (only during first request). At build time -> add it to the returned paths in getStaticPaths. At runtime -> use fallback: true/blocking. You decide
I wouldn’t want to have hour-long builds so I favour the latter option