Module 4 ended with a complaint: on every visit, AgendaViva queries the list of venues, which changes once a year. Before fixing that with a cache, it's worth putting in order what you've seen scattered around since 01-02. You know there are shells, holes, symbols in the next build table and errors that demand a <Suspense>. What's missing is the rule that ties them together.

This lesson spells it out. You'll see which work is done ahead of time at build and which waits for the request, how Next.js decides with Cache Components without anyone declaring a route's mode, how to read the result and what each prerendering error means. At the end we'll classify every AgendaViva route and have the work plan for the module.

  1. When a component runs

A Server Component is a function that runs on the server. The question is when it gets called:

Moment Who waits What's known How many it serves
Build (next build) Nobody The code and the data available at that point Every visitor, until it's regenerated
Revalidation, in the background Nobody The same, plus the visited URL Every visitor
Request One visitor Everything: URL, cookies, headers, time That visitor

The first two are called prerendering: HTML and the RSC Payload are produced before they're needed, and stored. The third is called rendering at request time, or dynamically.

For years the question was asked per route: "is this page static or dynamic?". A single cookie read turned the whole page dynamic, and the decision was forced with options like export const dynamic. That's still how Next.js works without Cache Components, and you'll see it in 05-06.

With Cache Components the question is asked per component. Every route is always prerendered, as far as possible, and whatever can't be is left as a hole that's filled in at request time. This is partial prerendering (PPR), the only model for pages with this configuration. A page with no holes is fully static; one where the hole takes up everything is dynamic. They're the two ends of the same scale.

  1. How Next.js decides

There's no heuristic over the source code. Next.js runs the component tree without a request and watches what happens. Everything a component can do falls into one of these five classes:

Class Examples When prerendering
Deterministic JSX, calculations, import, fs.readFileSync Completes: into the shell
Cached A function with 'use cache' Runs, is stored and goes into the shell, unless its lifetime is too short (05-03)
Uncached async Query, fetch, io(), connection() Stops: hole
Request data cookies(), headers(), searchParams, unknown params Stops: hole
Synchronous and unpredictable Date.now(), Math.random(), crypto.randomUUID() Error: it can't stop and mustn't be frozen

The first four sort themselves out. The fifth forces a decision, and it gets its own section.

flowchart TD
    A["The component runs<br/>without a request"] --> B{"Does it finish?"}
    B -- "Yes" --> C["Its HTML goes into the shell"]
    B -- "It stops at a wait" --> D{"Is there a Suspense<br/>above it?"}
    D -- "Yes" --> E["The fallback goes into the shell<br/>and the content is streamed"]
    D -- "No" --> F["Error: it blocks prerendering"]
    B -- "It reads the clock or randomness" --> G["Error: unstable value"]

2.1. What doesn't make a component dynamic

The table clears up three common misunderstandings:

  • Being async doesn't make it dynamic. An async component that only waits for cached data is prerendered in full.
  • Being inside a <Suspense> doesn't either. The boundary says what to show if something stops; if nothing stops, the content goes into the shell and the fallback isn't used.
  • Calling an async function of your own isn't the same as doing I/O. What matters is what's at the end of the chain.

And one the other way around: reading a local file can be a hole. fs.readFileSync is synchronous and is considered deterministic. await readFile(…) is async I/O, indistinguishable from a query. If the file doesn't change, the recommendation is to read it at the top level of the module:

import { readFile } from 'node:fs/promises'

// Read once, when the module loads: it plays no part in rendering
const terms = await readFile('./content/terms.txt', 'utf-8')

export function TermsOfUse() {
  return <p>{terms}</p>
}

Determinism has a less obvious corollary: a database with a synchronous API, such as node:sqlite, gets queried at build time without warning, and its result stays in the shell until the next deployment. If you want it on every request, you have to write await io() first. That's the original reason this function exists.

2.2. Route parameters, a special case

params can be in two classes. If Next.js doesn't know the values, it's request data, as it has been so far in /events/[slug]. If you give them to it with generateStaticParams (05-05), for those values it's deterministic, and the /events/jazz-night page is prerendered knowing its slug. The component's code is the same in both cases.

  1. The shell and its holes

A route's static shell contains what finished plus the fallbacks of what stopped. It's stored in two formats that come from the same tree: HTML, for full loads, and the RSC Payload, for navigations. It can be served from a CDN, without ever reaching the application server.

With partial prefetching a relative appears, the App Shell: the version of the shell that doesn't depend on the specific URL, one per route. It's what Link prefetches by default (02-03) and what's served when you visit a slug that wasn't prerendered. How it differs from the static shell:

Static shell App Shell
Used for The first load of a URL Navigations, and as a fallback for unknown URLs
Depends on known params Yes: one per prerendered URL No: one per route pattern
Cached content Whatever has a long enough lifetime Whatever has a stale of 5 minutes or more (05-03)

Let's look at an event page with this in mind, as it stands today:

/events/[slug]                                         class
RootLayout, ThemeProvider                              deterministic
PublicLayout
  Suspense(null) → SiteNotice                          uncached (io)
  Header
    Suspense → NavLink                                 URL, on the client
    Suspense(null) → FavoritesCounter                  browser only
  main
    EventDetailPage
      Suspense(EventDetailsSkeleton) → EventContent    request (params) and uncached
        Suspense → DayForecast                         uncached
      Suspense(cards) → RelatedEvents                  request and uncached
  Footer                                               deterministic

The shell has a header, a footer and two skeletons. Not a single word about the event. And yet the title, date, location and description are the same for everyone and change once a week: technically they're holes, but they don't have to be. That mismatch between the nature of the data and its class is what the next lessons fix.

Compare it with SiteNotice. It's also the same for everyone, but in 03-05 we decided it would be read at runtime so it could be changed without rebuilding. It's a hole on purpose.

  1. Reading the next build table

When it finishes, the build prints the routes with a symbol. With Cache Components they mean this:

Symbol Name What the build produced
○ Static All of the route's HTML
◐ Partial Prerender A shell; the rest, at request time
ƒ Dynamic Nothing: an empty HTML that was accepted, or an endpoint that depends on the request

This is AgendaViva's current table, abridged:

Route (app)
┌ ◐ /
├ ○ /_not-found
├ ƒ /api/events/[slug]/availability
├ ƒ /api/suggestions
├ ◐ /dashboard
├ ◐ /dashboard/events
├ ◐ /events
├ ◐ /events/[slug]
├ ◐ /venues
└ ◐ /venues/[slug]

○  (Static)             prerendered as static content
◐  (Partial Prerender)  prerendered as static HTML with dynamic server-streamed content
ƒ  (Dynamic)            server-rendered on demand

What it tells you and what it doesn't:

  • ◐ doesn't measure anything. A shell with the whole page minus one line and another with just the header get the same symbol. To find out how much is there, use the Navigation Inspector (04-04) or look at the first chunk with watch-response.mjs.
  • ƒ on a Route Handler is normal. Those that read the request always run. A GET that doesn't follows the same rules as a page and can come out as ○.
  • ƒ on a page is a warning sign. It means an empty shell was accepted with instant = false.
  • Revalidate and Expire columns. They appear when a route contains cached data, with the shortest lifetime of those it uses. We don't have any yet.
  • Grouped rows. When there's a generateStaticParams, the pattern appears without a symbol, and below it come the fallback row and one row per generated URL. You'll see them in 05-05.
  • JavaScript sizes aren't there. They were removed from this output in version 16; bundle analysis is done with another tool (10-02).

Make this table a habit. If a route that was ○ shows up as ◐ after a change, someone has introduced a wait. Comparing two builds is the cheapest regression test there is.

  1. Prerendering errors

When execution reaches a dead end, Next.js doesn't choose for you. In development it shows it in the error overlay and in the terminal, with the exact line; at build time, it stops the build. The names match the classes from section 2:

Error What happened outside a <Suspense>
blocking-prerender-dynamic An uncached wait: query, fetch, connection()
blocking-prerender-runtime Request data, or a cache with too short a lifetime
blocking-prerender-client-hook useSearchParams, usePathname or useParams with the URL still unknown
blocking-prerender-current-time The clock (inside or outside a boundary)
blocking-prerender-random Math.random() (inside or outside)
blocking-prerender-crypto crypto.randomUUID() and the like (inside or outside)

At build time, the first two are reported together, because they can't always be told apart. And the trace is usually poor: it points to body and html, since the code is minified. There are two options for debugging it, which can be combined:

npx next build --debug-prerender --debug-build-paths="app/(public)/events/**/page.tsx"

--debug-prerender turns off server minification, generates source maps and carries on with the other routes after the first failure. --debug-build-paths limits the routes. Never deploy a build produced with the first one. In practice, opening the route with npm run dev is usually enough.

5.1. The clock and randomness

These operations aren't waits: they return a value instantly. When prerendering, that value would be baked into the HTML and served to everyone for hours. Since there's no await to stop at, a <Suspense> doesn't help, and neither does instant = false: the error happens during prerendering itself.

The ways out depend on what you mean by the time:

You want… Solution
The time of this visit await io() first, inside a <Suspense>
The time the content was prepared Read it inside a function with 'use cache': it's stored and renewed along with the data
The visitor's time, or a "3 minutes ago" A Client Component, which calculates it in the browser
How long something takes, for a log performance.now(), which isn't watched
import { Suspense } from 'react'
import { io } from 'next/cache'

// Error: the build time would be frozen in place
function UpdatedAtWrong() {
  return <p>Updated: {new Date().toISOString()}</p>
}

// The time of each visit
async function UpdatedAt() {
  await io()
  return <p>Updated: {new Date().toISOString()}</p>
}

export function Notice() {
  return (
    <Suspense fallback={<p>Updated: …</p>}>
      <UpdatedAt />
    </Suspense>
  )
}

Only calls that read the clock are watched: new Date() with no arguments, Date() and Date.now(). formatDateTime(event.startsAt) works with a date that's already given and is deterministic. The rule covers everything that's part of the shell, including <Suspense> fallbacks, loading.tsx, error.tsx and not-found.tsx.

Remember too, from 04-05, that reading a cookie first doesn't entitle you to read the clock afterwards: with partial prefetching, that code can also run during a prerender. The await io() is what guarantees it. The documentation now prefers io() over connection() for this, because the former works the same inside a cached function.

And what if the read is inside a dependency? The error points to your call. It's handled the same way: cache it if the result can be shared, or call it after io() if it can't.

  1. The three ways out

For waits, the message always offers the same ones: stream, cache and block. They're neither equivalent nor interchangeable:

Stream Cache Block
How <Suspense> above it 'use cache' on the function or the component export const instant = false
What the visitor sees A fallback, then the content The content, in the shell Nothing, until it's all there
Freshness Up to the instant Whatever the cache allows Up to the instant
Cost per visit Server work None while it's valid Server work
Works for visitor data Yes No; it's passed as an argument (05-02) Yes
Makes you think about The skeleton When to invalidate Why

The choice comes from two questions about the data, not about the code:

flowchart TD
    A["Data you have to wait for"] --> B{"Is it the same for<br/>many visitors?"}
    B -- "No" --> C["stream"]
    B -- "Yes" --> D{"Is it acceptable for it to be<br/>a few minutes behind?"}
    D -- "No" --> C
    D -- "Yes" --> E["cache"]
    C --> F{"Does the page make sense<br/>without it?"}
    F -- "Yes" --> G["Suspense close to the data"]
    F -- "No" --> H["loading.tsx or a page-level boundary"]

block isn't in the diagram because it's hardly ever the answer. It has three reasonable uses: a route with nothing useful to show beforehand, a gradual migration (05-06) and diagnosis. It's worth knowing what it does and what it doesn't:

  • It switches off a check, not a mechanism. If the route can be prerendered, it's prerendered anyway. It isn't the equivalent of the old force-dynamic.
  • It only affects the segment that exports it during navigations; the ones below are still validated.
  • It doesn't silence clock and randomness errors.
  • It doesn't give you back control of the status code: the response starts with a 200 regardless (02-04).

The opposite requirement exists too: ensureStatic, since version 16.4. With export const ensureStatic = 'navigation', the build fails if the route stops being fully static, even if the dynamic part is under a <Suspense>. There are less strict levels, 'shell' and 'prefetch'. It's useful for legal or editorial pages whose cost must be zero; in a moment you'll see why AgendaViva can't use it yet.

6.1. Two separate validations

One last detail avoids surprises. Next.js checks two things:

  • That each page produces a non-empty shell. This is validated in development and at build time, which fails.
  • That each navigation shows something instantly. A high <Suspense> can cover the full load and not the navigation between two sibling pages, because it sits above the layout they share (04-04). This validation appears in development.

So npm run build passing doesn't mean navigations are instant. Go through the site in development and pay attention to the warnings.

  1. AgendaViva, route by route

With the classes and the ways out in hand, here's the inventory and the goal of the module:

Route or area Data Nature Today Chosen way out
/: upcoming events Query Shared, changes daily stream cache
/: events in your district Cookie and query The first is personal, the second shared stream stream, with the query in cache
/events: form searchParams and districts Request; the districts are shared stream stream, districts in cache
/events: list searchParams and query Request; shared result per filter stream stream, frequent results in cache
/events/[slug]: event page params and query Shared, rarely changes stream cache and known URLs (05-05)
/events/[slug]: spots Query Shared, changes every minute in the event page stream, in its own hole
/events/[slug]: forecast External API Shared, changes by the hour stream cache
/venues and venue pages Queries Shared, barely changes stream cache
/dashboard/** Queries One organizer's; they must see what they've just saved stream stream
Site notice Environment variable Shared, changed without rebuilding stream stream

Three decisions deserve a comment.

The spots come out of the event page. If the event page is cached with spotsLeft inside, the number ages along with it. By moving it into a hole, everything else can be in the shell and the only thing you wait for is a two-column query. This is the most profitable pattern in partial prerendering: isolate what's volatile to free up what's stable.

The dashboard isn't cached. It gets few visits, each one different, and whoever edits wants to see their change. Adding a cache would bring invalidations and no gain.

The notice will remain a hole, and since it's in PublicLayout, no public page will reach ○ while it exists: they'll all be ◐, including those with no other wait. The real cost is that every full load needs the server to handle that hole, however small it is. We accept it: being able to announce an incident without rebuilding is worth it. If one day it weren't, the next build table will tell us the moment the last hole disappears, and ensureStatic will stop it from coming back.

Common Mistakes and Tips

  • Reasoning by routes. "This page is dynamic" is no longer a property of the page, but of some of its parts.
  • Believing that async or <Suspense> makes a component dynamic. What it waits for does.
  • Wrapping the whole page to silence an error. It builds with an empty shell.
  • Using instant = false as a synonym for "dynamic", or expecting it to fix a Date.now().
  • Putting the clock or randomness in a <Suspense> fallback.
  • Reading a file that doesn't change with await readFile, instead of doing it in the module.
  • Signing off on a route because of its ◐. Look at what the shell contains.
  • Caching personal data to get rid of an error. One person's data isn't shared; the way out is stream.

Exercises

Exercise 1: classify

Say which class each snippet belongs to when prerendering and what Next.js does, assuming there's no <Suspense> above it: (a) const texts = JSON.parse(fs.readFileSync('./texts.json', 'utf-8')); (b) const { q } = await searchParams; (c) const id = crypto.randomUUID(); (d) await new Promise((r) => setTimeout(r, 10)); (e) new Intl.DateTimeFormat('en-US').format(event.startsAt); (f) const start = performance.now().

Solution

Class Result
a Deterministic Into the shell, with the file's contents at build time
b Request data blocking-prerender-runtime error
c Unpredictable blocking-prerender-crypto error; it would also happen inside a <Suspense>
d Uncached async blocking-prerender-dynamic error: a wait is a wait
e Deterministic Into the shell: the date is data, the clock isn't read
f Not watched Into the shell; it's for measuring, and its value shouldn't be rendered

Exercise 2: reading a build

A colleague adds the text © {new Date().getFullYear()} AgendaViva to Footer. Which routes fail? What happens if they wrap it in a <Suspense>? Propose a solution for each interpretation: the year of the visit and the year the page was prepared.

Solution

Every route that uses PublicLayout fails, because the footer is part of its shell. A <Suspense> changes nothing: there's no wait to stop at. For the year of the visit, await io() in a component of its own under a boundary; that's a disproportionate cost for a year. The sensible choice is the second, with a cached function with a long lifetime:

// components/footer.tsx
import { cacheLife } from 'next/cache'
import { SITE_NAME } from '@/lib/site'

async function getYear() {
  'use cache'
  cacheLife('days')
  return new Date().getFullYear()
}

export async function Footer() {
  const year = await getYear()

  return (
    <footer className="border-t border-slate-200 py-6 text-center text-sm text-slate-600">
      © {year} {SITE_NAME}, the cultural events guide for Vallenar del Río
    </footer>
  )
}

Footer becomes async and stays in the shell, with no <Suspense>: it only waits for cached data. It's renewed once a day, so on New Year's Day it may be a few hours behind. The course keeps this change; the directive and cacheLife are explained in the next two lessons.

Exercise 3: designing a page

We want a /today page with: a fixed headline; today's events; the forecast; the number of the visitor's favorites taking place today; and a counter of people currently viewing the page. Decide the way out for each part and explain what the shell would contain.

Solution

Part Decision Reason
Headline Deterministic It's always in the shell
Today's events cache Shared. "Today" depends on the clock: it's read inside the cached function, with a lifetime of minutes
Forecast cache Shared; changes by the hour
Today's favorites Client Component They're in localStorage; the server doesn't know them. It receives today's identifiers as a prop
People online Browser, with polling Changes every second; the server mustn't rerender the page for it

The shell would have the headline, the events and the forecast, and the page wouldn't need any server work on each visit, except for the SiteNotice hole. The risk is at midnight: with a fifteen-minute lifetime, yesterday's list may be shown until it's regenerated.

Conclusion

Next.js runs each route without a request and stores everything that finishes. Whatever stops leaves a hole if there's a <Suspense>, and an error if there isn't; whatever reads the clock or randomness is always an error, because it can't stop. That's where the shell, the symbols in the table and the messages you've been seeing since 01-04 come from. Faced with a wait there are three ways out, and the choice depends on the data: stream what's personal or instantaneous, cache what's shared and can tolerate a delay, and block only with a reason.

AgendaViva's inventory says most of our holes are unnecessary. In Cache Components and the use cache Directive we'll start closing them: what the directive stores, with what key, where and with what limits.

© Copyright 2026. All rights reserved