-
SummaryFrom what I understand, PPR gives you the ability to combine static and dynamic content in the same route. However, there's also React's If you look at the example in the PPR docs, couldn't this: import { Suspense } from 'react'
import { User, AvatarSkeleton } from './user'
export const experimental_ppr = true
export default function Page() {
return (
<section>
<h1>This will be prerendered</h1>
<Suspense fallback={<AvatarSkeleton />}>
<User />
</Suspense>
</section>
)
} be rewritten to this (using React's export const experimental_ppr = true
export default function Page() {
const session = (cookies()).get('session')?.value
return (
<section>
<h1>My example with React's `use` API</h1>
<Suspense fallback={<AvatarSkeleton />}>
<User sessionPromise={session} />
</Suspense>
</section>
)
}
// "use client"
function User(sessionPromise) {
const session = use(sessionPromise)
return '...'
} Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @mtlaso PPR vs React's
|
Beta Was this translation helpful? Give feedback.
-
Hi, The key bit in your example is that, without PPR, every time Page is hit - you'd need to render the entire top-down tree. You can think of PPR as an enhancement that at build time, knows how to carve out the static shell, the bits that don't depend on the cookie, or dynamic behavior. The static shell boundary ends at the Suspense boundary. So with PPR on, at build time the shell is calculated and extracted, and then on every new request, or when prefetching a page, the shell can be reused, and then we only need to collect the dynamic bit, and in your case, that'd get streamed to the client interactive javascript, rather than waiting for the whole thing to render server side, or being streamed into RSC slots in the client. |
Beta Was this translation helpful? Give feedback.
Hi,
The key bit in your example is that, without PPR, every time Page is hit - you'd need to render the entire top-down tree.
You can think of PPR as an enhancement that at build time, knows how to carve out the static shell, the bits that don't depend on the cookie, or dynamic behavior. The static shell boundary ends at the Suspense boundary.
So with PPR on, at build time the shell is calculated and extracted, and then on every new request, or when prefetching a page, the shell can be reused, and then we only need to collect the dynamic bit, and in your case, that'd get streamed to the client interactive javascript, rather than waiting for the whole thing to render server side, or being …