Menu

Partial Prerendering and the Static Shell

Lesson 4: Partial Prerendering and the Static Shell

What is Partial Prerendering?

Partial Prerendering (PPR) lets a single page be partly static and partly dynamic. With Cache Components enabled, it is the default behaviour.

Part of the page Rendered Delivered
Static content (layout, headings, cached data) At build time Instantly, as the static shell
Dynamic content inside <Suspense> At request time Streamed into the same response

Example

// app/dashboard/page.tsx
import { Suspense } from 'react';
import { cookies } from 'next/headers';

export default function Dashboard() {
  return (
    <main>
      <h1>Your learning dashboard</h1>          {/* Static */}
      <FeaturedCourses />                        {/* Cached with 'use cache' */}

      <Suspense fallback={<ProgressSkeleton />}>
        <MyProgress />                           {/* Dynamic: reads cookies */}
      </Suspense>
    </main>
  );
}

async function MyProgress() {
  const session = (await cookies()).get('session')?.value;
  const progress = await getProgress(session);
  return <ProgressList items={progress} />;
}

How it works

  1. At build time, Next.js renders the page until it reaches something dynamic.
  2. Everything outside the Suspense boundary, plus 'use cache' output, becomes the static shell.
  3. The fallback (ProgressSkeleton) is included in the shell.
  4. On a request, the shell is sent immediately; MyProgress runs and streams in.

**connection()** marks a component as request-time even if it uses no other dynamic API, for example when it reads the current time or a random value:

import { connection } from 'next/server';

async function LiveClock() {
  await connection();
  return <p>Server time: {new Date().toLocaleTimeString('en-IN')}</p>;
}

Faster navigations (Next.js 16.3): with cacheComponents and the opt-in partialPrefetching flag, links prefetch reusable loading shells so client navigations show UI immediately. The Instant Insights panel in Next.js DevTools points out navigations that are not instant.

Common mistakes

Mistake Effect Fix
Dynamic data outside any Suspense boundary Build error with Cache Components Wrap it in <Suspense> or cache it
One Suspense around the whole page Static shell is almost empty Wrap only the dynamic sections
Skeletons that differ in size from content Layout shift Match the final dimensions

Key takeaways

  • PPR serves a static shell instantly and streams dynamic "holes".
  • Suspense boundaries decide where the shell ends and dynamic content begins.

Try it: Build the LearnHub dashboard with a static heading, a cached "Featured courses" section, and a dynamic "My progress" section inside Suspense.


Nextjs Tutorial

J

Jebasta





Get in Touch For Details