how work generateStaitcParams with sub dynamic routes?
Unanswered
Somali posted this in #help-forum
SomaliOP
hello
i have this structure:
should i use generateStaticParams inside root layout for [lang] and [slug]? or only for langs and call another generateStaticParams inside [slug]/page.js?
i have this structure:
app
[lang]
[slug]
page.jsshould i use generateStaticParams inside root layout for [lang] and [slug]? or only for langs and call another generateStaticParams inside [slug]/page.js?
11 Replies
@Somali hello
i have this structure:
app
[lang]
[slug]
page.js
should i use generateStaticParams inside root layout for [lang] and [slug]? or only for langs and call another generateStaticParams inside [slug]/page.js?
Northeast Congo Lion
I have done it on page.js for generateStaticParams and it works ok
site is in production, no problems. seems to pre-render well
@Northeast Congo Lion I have done it on page.js for generateStaticParams and it works ok
SomaliOP
do you have root page.js for home page?
@Somali hello
i have this structure:
app
[lang]
[slug]
page.js
should i use generateStaticParams inside root layout for [lang] and [slug]? or only for langs and call another generateStaticParams inside [slug]/page.js?
both work, but keep in mind you can't have a static layout and dynamic pages
so moving the generateStaticParams to pages might end up being mandatory anyway if afterwards you add a dynamic page under the same layout
PPR might change the game though
The State of JavaScript survey open source codebase if you want to see a real-life app
note that many generateStaticParams are commented out due to various weird bugs we had... 14.1 might be more stable when released