Next.js Discord

Discord Forum

PPR Use Case?

Unanswered
Golden northern bumble bee posted this in #help-forum
Open in Discord
Golden northern bumble beeOP
If my website has auth state in the header (user profile button / sign in button) on all pages, there is no way to make any pages static unless I move the auth state to a client component and do all data fetching on the client, right?

Is there where PPR will eventually let us have certain parts static, and others dynamic, like the auth state in the header?

35 Replies

Is that expected and same as you?
@Golden northern bumble bee I’m currently doing that now, but my pages are still dynamic
Argentine ant
yeah that's normal, anything that's outside of those server components are going to be static anyways and it works well for us
@Argentine ant yeah that's normal, anything that's outside of those server components are going to be static anyways and it works well for us
Golden northern bumble beeOP
But all pages are dynamic (because of the auth component in navbar, for this example) which means every time someone goes to it the server spins up and generates it. Even if the data fetch(s) are cached it still generates the page each time (would be faster I guess).

Compare that to a static generated page approach (like ISR), where the page is just sent back instantly and not generated at request time.

I THINK this is what PPR fixes, but I have no idea and there’s so much experimental and deprecated stuff floating around now it’s hard to know what a “proper” approach even looks like
Golden northern bumble beeOP
Yeah performance wise, totally fine on my end too. More the billing and bandwidth costs but I haven’t really seen this out in the wild yet so TBD
@Golden northern bumble bee Yeah performance wise, totally fine on my end too. More the billing and bandwidth costs but I haven’t really seen this out in the wild yet so TBD
Argentine ant
we serve a lot of users and don't really have a big issue with billing and dynamic routes
and we're fully on vercel too
Golden northern bumble beeOP
Ah ok good to know, I’m likely hyper-optimizing where it’s not really needed but once PPR is stable I’ll probably revisit this
Thanks for your help!
@Golden northern bumble bee Ah ok good to know, I’m likely hyper-optimizing where it’s not really needed but once PPR is stable I’ll probably revisit this
Argentine ant
i'm exactly the same haha - but honestly our stuff is so quick in production i'm happy with how it currently works anyways
on our e-commerce store, we manage cart fetches client-side
and that makes the rest static, so it's extremely fast but that was only because RSCs were not around when we built that component
they summed it up quite nicely here:
As a developer, you do not need to choose between static and dynamic rendering as Next.js will automatically choose the best rendering strategy for each route based on the features and APIs used. Instead, you choose when to cache or revalidate specific data, and you may choose to stream parts of your UI.
@Argentine ant and that makes the rest static, so it's extremely fast but that was only because RSCs were not around when we built that component
Golden northern bumble beeOP
Yeah that makes sense then, I guess that was what I was thinking but for the auth, but if I can do it on the server I mind as well, but sacrifice the static pages, not 100% sure
Argentine ant
i have just found something though, no idea if this has changed/has any truth to it:
someone mentioned having them in nested server components doesn't cause it to opt into dynamic for the entire route
Golden northern bumble beeOP
Hmm I want to say that’s outdated but I’d have to check, a nested server component would be like if the page had another server component in it? That feels like an unintentional bug lol
Cause I guess my entire app is dynamic because of the auth state, and that’s not top level page nor layout
Argentine ant
yeah so i think they're saying in the case of having:

<Navbar> <Suspense><Auth /></Suspense> </Navbar>
also are you sure you're entire app is dynamic?
i just checked some of our code for a site that does have this exact setup with the navbar in the root layout and it seems quite a few of our pages are static
@Argentine ant also are you sure you're entire app is dynamic?
Golden northern bumble beeOP
Yeah, the build output marks every page as dynamic
@Argentine ant i just checked some of our code for a site that does have this exact setup with the navbar in the root layout and it seems quite a few of our pages are static
Golden northern bumble beeOP
Interesting, maybe something else is causing this. I’ll check again without the auth there at all
Just stumbled upon this too, seems to be similar situation kinda?
wow, it's not showing the full tailwind classnames
what's the extension name?
and how to see and edit it then?
@James4u what's the extension name?
Tailwind Fold, you can edit it when you click on the classname
@Argentine ant i just checked some of our code for a site that does have this exact setup with the navbar in the root layout and it seems quite a few of our pages are static
Golden northern bumble beeOP
Just checked this on my site, removing the auth from header resulted in static pages. So its definitely the auth in my case at least.
🤷‍♂️