# Partial Prerendering (PPR)

> Static shells with dynamic holes.

Subject: Next.js | Lesson 64 of 65 | 4 min read
Interactive lesson: https://codewithanimation.in/nextjs/partial-prerendering
Previous: [React Compiler Integration (v15)](https://codewithanimation.in/nextjs/react-compiler.md) | Next: [Dynamic IO API (v15)](https://codewithanimation.in/nextjs/dynamic-io.md)

## The Best of Both Worlds

For years, developers had to choose between Static Site Generation (fast, but generic) and Server-Side Rendering (personalized, but slower).

**Partial Prerendering (PPR)** merges them. During the build step, Next.js generates a static HTML shell of your page. However, it leaves 'holes' wherever it finds a `<Suspense>` boundary wrapping dynamic data.

## Fixing the All-or-Nothing Trap

Before PPR, if a static e-commerce homepage wanted to display the user's name in the header (which requires reading a cookie), the *entire page* was forced to become dynamic, severely harming TTFB.

With PPR, the user receives the static homepage layout instantly from the Edge CDN. A few milliseconds later, the personalized header streams into the `<Suspense>` hole.

## Implementation

To use it in Next.js 15, enable it in config and explicitly opt-in at the route level:

```typescript
// app/page.tsx
import { Suspense } from 'react';
import { CartCount, Skeleton } from '@/components';

// Opt into PPR
export const experimental_ppr = true;

export default function Page() {
  return (
    <main>
      <StaticHero />
      <Suspense fallback={<Skeleton />}>
        {/* This streams in dynamically! */}
        <CartCount />
      </Suspense>
    </main>
  );
}
```

## Common mistake: Rethinking Component Boundaries

The main pain point with PPR is learning to architect your component tree correctly. If you call a dynamic function (like `cookies()`) *outside* of a `<Suspense>` boundary, you ruin the static shell.

You must carefully isolate dynamic data fetching into granular Server Components wrapped in Suspense.

## Try it: PPR Streaming Visualization

Watch how a static shell is served instantly from the edge, followed by a dynamic payload streaming into the Suspense boundary.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/nextjs/partial-prerendering

## Check yourself

### Question 1

How does Partial Prerendering (PPR) handle a page that contains both static content and a dynamic cookie read?

- A. It falls back to Client-Side Rendering for the entire page.
- B. It serves the static shell instantly from the CDN, and streams the dynamic component into a Suspense boundary.
- C. It forces the entire page to wait for the dynamic cookie read before sending any HTML.
- D. It throws a compilation error because static and dynamic content cannot mix.

Correct answer: B

PPR provides the best of both worlds. The static HTML shell is served instantly, resulting in an incredibly fast TTFB, while the personalized dynamic data streams in behind Suspense boundaries.

- Why not C: That is traditional SSR, not PPR.

## Remember this

- PPR combines SSG (static shell) and SSR (dynamic streaming) on the same page.
- It solves the 'all-or-nothing' rendering dilemma.
- You must wrap dynamic Server Components in `<Suspense>` to create the 'holes' for the static shell.
- Dynamic functions called outside of Suspense will break the static shell.
