Dynamic routes and partial pre-rendering (PPR) #83445
Unanswered
valleywood
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'm migrating a large solution from Page router to App router and was exited about the PPR functionality.
We're having a dynamic slug for our products (there are thousands of them) like this products/[slug]
The idea was to have product information (that doesn't change that often and are not user group specific etc) to be rendered server side so that it is included in the initial document file sent to the browser. Then things like price and product recommendations could be streamed with Suspense to the client dynamically.
To make the routes dynamic i added a
generateStaticParams
function like this in my products/[slug]/page.tsx fileThis works fine as long as i wrap both my components inside a Suspense like this:
This however makes both ProductData and RelatedProducts being streamed to the client leading to a worse user experience and decreased LCP values etc.
What I would like is this:
This would actually make the ProductData appear in the initial document and RelatedProducts being streamed just as i wanted.
However this setup causes console errors in the browser:
I've tried with the code below and then it works as expected with no console error and the product information being rendered in the initial document but that isn't a feasible solution having thousands of products that is updated/added/deleted continuously
Is this a known limitation of PPR and should I go for a ISR + client setup instead or does anyone know of a way to have dynamic routes (with slugs) working with PPR?
Beta Was this translation helpful? Give feedback.
All reactions