Dynamic routes and partial pre-rendering (PPR) #83445
Replies: 2 comments
-
Sorry you ran into this – we're currently working on improving these errors + documenting all the use cases for the upcoming stable release, but it's all admittedly a bit confusing right now! My first question is about your desired behavior. You wrote
When you say rendered server-side, do you mean prerendered? Like during build time? Based on the rest of your comment, I gather that you don't want to prerender the pages, since there are many dynamic slugs. In that case, do you just mean that you want to server-render the pages at request time? |
Beta Was this translation helpful? Give feedback.
-
@samselikoff Thanks for reaching out and sorry I was being a bit sloppy here in my description about "server-side" The desired behavior was actually having ISR with on-demand build at runtime (thinking that having dynamic slug with thousands of product pages pre-rendered at build time wasn't the best choice probably. Products can be added, removed or updated randomly anyways) So I'd like the users to get a cached markup served in the document file (for user two and onwards) which is the traditional ISR pattern. Then I thought i could add What I've come to realize is that having ISR with "holes" like this with
I actually got around the first error display in the original post by just dropping the generateStaticParams function completely but it seems like the solution with That worked just fine for the ISR case. Tried in all possible ways to work with
Reading some more about this issue here: |
Beta Was this translation helpful? Give feedback.
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