getStaticPathsWithProps #17079
vibhanshu909
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A method to get all the static paths along with their props.
As of now for
SSG
nextjs provides us two methods:getStaticPaths
- for fetching all the paths whose page will be generated at build time.getStaticProps
- for fetching the required props for a page.Now a page can
SSG
if no additionalparams
are required ex:/privacy_policy
in which case, onlygetStaticProps
can be used to fetch the requiredprops
a build time.But if a page needs additional
params
ex:/post/[slug]
then,getStaticPaths
&getStaticProps
are used in conjuction, ex:The problem here is that we need to call the
fetch
APIn+1 number of times
, wheren
is the number of posts.This doesn't seem to be a big problem at first but when the post increase to thousands and more, then the build time keeps increasing along, additionally it also increases the load on the API server(if someone has an API consumption limit, it will get exhausted quickly).
Suggested Solution
There are 3 ways to solve this problem right now:
Beta Was this translation helpful? Give feedback.
All reactions