Next.js Course
Next.js
/
Advanced

Partial Prerendering (PPR)

Definition

An experimental Next.js architecture that combines the ultra-fast instant loading of Static Site Generation (SSG) with fully dynamic Server-Side Rendering (SSR) on the exact same page.

Explain Like I'm New

Historically, a page had to be 100% Static or 100% Dynamic. If you added a dynamic 'Shopping Cart' icon to a static 'Blog', the whole page became slow. PPR fixes this. The server instantly sends a static HTML shell (the blog), leaving a 'hole' for the shopping cart, which is streamed in dynamically milliseconds later.

Real World Example

An E-commerce product page. The product image, title, and description are served instantly as a static cache. The 'Add to Cart' button (which needs to check live inventory) is dynamically rendered and popped into the page.

Common Use Cases

  • E-commerce
  • Personalized static pages

Interactive Example

/* 
  Note: PPR is currently an experimental feature in Next.js 14+
  Requires 'experimental: { ppr: true }' in next.config.js
*/
import { Suspense } from 'react';
import { StaticProductDetails } from './components';
import { DynamicCartStatus } from './components'; // Relies on cookies/DB

export default function ProductPage() {
  return (
    <main>
      {/* ⚡ INSTANT: This is pre-rendered at build time and served from CDN */}
      <StaticProductDetails />
      
      {/* 
        🕳️ THE HOLE: Suspense tells PPR this part is dynamic.
        The fallback is served instantly with the static shell. 
        The actual Cart is generated dynamically on the server and streamed in.
      */}
      <Suspense fallback={<div className="w-10 h-10 animate-pulse bg-gray-200" />}>
        <DynamicCartStatus />
      </Suspense>
    </main>
  );
}

Interview Questions

basic

  • In Partial Prerendering, does the static shell of the page wait for the dynamic parts to finish loading?

intermediate

  • How do you define the 'boundary' between the static shell and the dynamic content in PPR?

Flash Cards

Question

Does it wait?

Click to reveal answer
Answer

No! That is the genius of PPR. The static shell is sent instantly from a CDN edge network, resulting in zero wait time for the user.

Question

How to define boundary?

Click to reveal answer
Answer

By wrapping the dynamic components in a React `<Suspense>` boundary. Next.js knows everything outside Suspense is static, and everything inside is dynamic.