Capítulo 201 de 456
cacheComponents (next.config.ts flag) enables component/function-level caching via use cache and makes data fetching dynamic-by-default, prerendering a static shell while dynamic parts stream in.
next.config.ts that turns on Cache Components (use cache directive, cacheLife, cacheTag).runtime = 'edge' export must migrate; other JS runtimes aren't guaranteed to work.cacheComponents on, Partial Prerendering is the default App Router behavior; experimental.ppr and experimental_ppr are removed/unnecessary.<Activity> navigation: when enabled, Next.js uses React's <Activity> to keep previous routes mounted (mode "hidden") instead of unmounting on navigation, preserving component state; effects clean up when hidden and recreate when visible.import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
}
export default nextConfig
| Version | Change |
|---|---|
| 16.0.0 | cacheComponents introduced; unifies ppr, useCache, dynamicIO flags. |
runtime = 'edge': incompatível com cacheComponents, migre antes de habilitar.cacheComponents: true liga use cache, cacheLife, cacheTag e PPR de uma vez só.experimental.useCache/experimental.dynamicIO do Next 15 (ver guia de upgrade da v16).<Activity>, o que pode exigir tratamento especial de dropdowns/dialogs (ver guia "Preserving UI state").use cache.