App Router - Best way to get SSG for routes with a param that only effect client side components #67521
Unanswered
Kmarti1
asked this question in
App Router
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.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a page in my project with the route
app/[locale]/users/[id]/profile/...
The profile layout, and subsequent pages of the profile are server components that just provide the template of the page and don't actually run a query. The pages contain client components that do the actual user specific queries and display that content.
For the locale, I have defined generateStaticParams for the available languages. But for the id, I have tried using
export const dynamic = 'force-static'
But this seems to just tell the route to ignore non-param dynamic elements like search queries.
As a work around I tried moving the id to a query with the route
app/[locale]/users/profile/...?id={user_id}
And through the use of the 'force-static' export it worked as desired and I got SSG. The cold page load is noticeably faster than putting the id in a param.
For a little more context, if I build the project, the param id approach doesn't give me SSG per locale, it just gives static content for the generic route. With the query approach I do get the proper localized SSG files.
Any suggestions would be great, thank you!
Beta Was this translation helpful? Give feedback.
All reactions