From Segments to Suspense: The Future of Next.js Caching

Bookmark
Rate this content

Next.js applications of today struggle with an architectural contradiction: entire routes must be either fully static or fully dynamic, forcing developers to sacrifice performance for freshness or vice versa. This all or nothing approach leads to redundant computation, increased costs, and slower user experiences.

In this session, we'll explore Cache Components — an experimental Next.js feature that introduces function-level caching through the `'use cache'` directive. Building on React's streaming capabilities and Partial Prerendering infrastructure, we'll demonstrate how to achieve granular control over what gets precomputed into static shells versus what streams dynamically. You'll learn practical patterns for common scenarios like expensive computations, real-time data requirements, and the sophisticated middle ground between them. We'll examine production migrations showing improved compute cost reductions and reduced Time to First Byte from global edge locations.

You'll leave with a new mental model for caching—not as a performance afterthought, but as a first-class architectural decision that lives alongside your components. Instead of choosing between "static" or "dynamic" routes, you'll understand how to compose cached and streaming content within the same component tree, creating applications that are both performant and architecturally honest about their data requirements.

This talk has been presented at React Advanced 2025, check out the latest edition of this React Conference.

FAQ

Cache Components guide developers in creating faster applications by providing feedback to prevent performance regressions. It ensures that dynamic data accesses are wrapped in a suspense boundary, enabling static content to be served initially and dynamic content to stream in later.

Suspense boundaries are used in Cache Components to allow dynamic data to stream in after the static content has been served. This ensures that applications can provide a static fallback for initial loads while maintaining flexibility for dynamic components.

With Cache Components enabled, the generateStaticParams function requires at least one parameter to prevent errors that could occur in production. This ensures that static content can be generated reliably, avoiding runtime errors related to dynamic data access.

Next.js 16 deprecated the revalidate export in favor of a new caching model that uses cache directives. This change allows developers to configure cache lifetimes more flexibly and co-locate caching information with the code that creates it, streamlining caching configurations.

Cache Components enable both static and dynamic rendering within the same page by using cache boundaries and suspense boundaries. This approach allows for static parts of a page to be served quickly while dynamic parts stream in as needed.

The dynamic segment configuration option was deprecated because Cache Components allow for a more granular approach to static and dynamic rendering. Developers can now use React's language to describe their application's state instead of relying on static configuration for dynamic behavior.

Cache directives in Next.js 16 provide a way to mark I/O operations as cacheable, allowing them to be included in static content. This reduces the need for dynamic rendering and improves the performance of applications by enabling more efficient caching.

Cache Components provide early feedback by detecting dynamic data access outside of suspense boundaries during development. This helps prevent runtime errors and ensures that applications are optimized for fast, static content delivery.

The concept of 'variants' refers to creating static shells that can be reused in different contexts, such as for logged-in and logged-out users. This approach uses headers, cookies, or query parameters to direct users to the appropriate static version, enhancing performance.

Cache Components in Next.js 16 aim to combine experimental features like partial pre-rendering and dynamic I.O. into a single concept. This provides a new programming model that allows for static and dynamic parts of a React application to compose together, improving performance and flexibility.

Wyatt Johnson
Wyatt Johnson
27 min
28 Nov, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Introduction to Cache Components in Next.js 16, transforming the app router with new features like partial pre-rendering, Dynamic I.O., and caching directives. Deep dive into static params generation in Next.js focusing on changes in generating static params for improved performance. Exploring challenges of generating static params and balancing static vs. dynamic rendering for better performance. Addressing challenges with cache components, optimizing static and dynamic rendering for improved performance. Understanding impact of parameters on rendering with cache components, managing dynamic components, and introducing suspense boundaries for faster page loads. Enhancing cache life APIs, introducing a new caching model for static outputs in Next.js. Revolutionizing cache management with granular control over cache lifetimes and dynamic segment configuration. Navigating data and caching in Next.js, exploring cache components guidance and caching differences between server and client components.

1. Exploring Cache Components in Next.js 16

Short description:

Introduction to Cache Components in Next.js 16, transforming the app router with new features like partial pre-rendering, Dynamic I.O., and caching directives. Aiming to provide developers with a comprehensive solution for fast and dynamic React applications.

How to Use React. Hello, everyone. Thanks for joining me today. Obviously, my name is Wyatt Johnson. I'm a software engineer on the Next.js team at Vercel.

Today's talk is a deeper exploration of some of the changes that we've introduced with Next.js 16, specifically Cache Components. Cache Components is the future of the Next.js app router that combines many of the experimental features we've been developing over the last few years into a single concept. Now, with a single configuration option, you can get the rendering techniques of partial pre-rendering, the dynamic detection of Dynamic I.O., and the new caching directives, like Use Cache.

Together, these features paint a much more complete future of the app router. I actually went on stage last year at Next.js Conf to discuss partial pre-rendering and Dynamic I.O. We wanted developers to understand the reasoning behind some of the technical decisions that we made, along with providing some concrete examples of how Dynamic I.O. improved the developer experience. Just like then, today we're going to talk about how Cache Components solves many of the problems that developers face today.

When we started development of the app router, our goal was to create a new way of developing React applications that offered fast and dynamic experiences for their users. App Router took advantage of React Server Components to enable everything from co-located data loading within their components, to data mutations powered by server actions. It meant that now, instead of writing GetStatic Props or GetServerSide Props, developers could just write React.

They could query their databases inside of their components, or access request data, like cookies. Next.js used this information it collected at build time to determine if a page could be rendered statically, or if it needed to render each request dynamically. But, there was a problem with this design. As developers started to build more and more complex applications, they had to be increasingly vigilant to ensure that they didn't introduce performance regressions.

Adding a component to a page that accessed request data meant that the entire page could not be rendered statically, leaving users waiting for their page to load. We had created a mountain road without any guardrails. Small mistakes could result in big impacts to performance. We needed a way to guide developers so that their applications were still fast, without sacrificing the flexibility offered by dynamic rendering.

After years of development, literally years, we think that Cache Components has that solution. It's not just a configuration option, it's actually a new programming model, as it provides a new way for static and dynamic parts of your React applications to compose together. Under this new model, components don't just co-locate their data, they also co-locate their caching. To help developers, Next.js now provides more feedback to ensure that they're guided towards creating the best version of their applications.

Now, when a component attempts to access request-specific data, like cookies, Next.js produces a build error if that component, or its parents, is not wrapped in a suspense boundary. This ensures that applications that want to show dynamic data can still have something static to send for initial load, streaming the dynamic content in afterwards.

2. Deep Dive into Static Params Generation in Next.js

Short description:

Introducing a new programming model with cache directives like useCache, focusing on changes in generating static params in Next.js for improved performance and potential pitfalls for inexperienced developers.

Other forms of I-O, such as fetch calls or database queries, are also automatically marked as dynamic, thanks to Dynamic I-O. To mark I-O as statically cacheable, the developer needs only annotate that code with a cache directive, such as useCache. We wanted to introduce this new programming model in a way that led developers to getting the most out of the framework. We also wanted to do this while introducing as few new APIs as possible, so developers wouldn't need to learn so many new concepts. Today, I'm going to focus on only a few of these changes that we've introduced with cache components.

We'll explore some of the changes to generate static params and deprecations of segment configuration options for revalidate and dynamic. First, let's explore the changes to generate static params. Walking through some parts of a fictional e-commerce application, we can illustrate these in action. This is our product page. As this page has dynamic path parameters, category, and slug, it's marked as dynamic by default. This means that when users try to visit a product page, they'll have a fresh page rendered on the server for each request. If these product pages are visited frequently, we may want to take advantage of static rendering so it can be served fast from the edge, improving the speed of navigations in the site.

To tell Next.js that we want to render this page statically, we need to export generateStaticParams to provide optionally some parameters that we want to prerender. Let's add that now. Perfect. Now when a user visits a product page for the first time, this page is rendered statically and can now be served fast for all subsequent visits. We're done, right? While this may have worked initially, this code masks a danger that inexperienced developers might miss. Days, weeks, or months later, a seemingly unrelated change in another component could silently break this page in production.

This particular class of error evades detection through Next.build, appearing only when the application is running in production. The culprit? This line. It's kind of hard to see at the bottom of the slide there. It's not that returning an empty array from generateStaticParams is inherently an error by itself. The bug itself manifests when a server component that was rendered on this page or layout attempts to access request data, such as headers. Let's update our page with an example of that to see how that works. Now, our product page includes our new userDeals component. Inside, it reads request headers to determine the user's country so it can present them with relevant deals for their region. When we run Next.build, everything looks good and it successfully deploys to production. When we try to navigate to one of these product pages, however, we get an error.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Simplifying Server Components
React Advanced 2023React Advanced 2023
27 min
Simplifying Server Components
Top Content
Watch video: Simplifying Server Components
React server components simplify server-side rendering and provide a mental model of components as pure functions. Using React as a library for server components allows for building a basic RSC server and connecting it to an SSR server. RSC responses are serialized virtual DOM that offload code from the client and handle interactivity. The client manifest maps serialized placeholders to real components on the client, enabling dynamic rendering. Server components combine the best of classic web development and progressive enhancement, offering the advantage of moving logic from the client to the server.
A Guide to React Rendering Behavior
React Advanced 2022React Advanced 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Building Better Websites with Remix
React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Top Content
Remix is a web framework built on React Router that focuses on web fundamentals, accessibility, performance, and flexibility. It delivers real HTML and SEO benefits, and allows for automatic updating of meta tags and styles. It provides features like login functionality, session management, and error handling. Remix is a server-rendered framework that can enhance sites with JavaScript but doesn't require it for basic functionality. It aims to create quality HTML-driven documents and is flexible for use with different web technologies and stacks.
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced 2023React Advanced 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
Watch video: React Compiler - Understanding Idiomatic React (React Forget)
Joe Savona
Mofei Zhang
2 authors
The Talk discusses React Forget, a compiler built at Meta that aims to optimize client-side React development. It explores the use of memoization to improve performance and the vision of Forget to automatically determine dependencies at build time. Forget is named with an F-word pun and has the potential to optimize server builds and enable dead code elimination. The team plans to make Forget open-source and is focused on ensuring its quality before release.
Using useEffect Effectively
React Advanced 2022React Advanced 2022
30 min
Using useEffect Effectively
Top Content
Today's Talk explores the use of the useEffect hook in React development, covering topics such as fetching data, handling race conditions and cleanup, and optimizing performance. It also discusses the correct use of useEffect in React 18, the distinction between Activity Effects and Action Effects, and the potential misuse of useEffect. The Talk highlights the benefits of using useQuery or SWR for data fetching, the problems with using useEffect for initializing global singletons, and the use of state machines for handling effects. The speaker also recommends exploring the beta React docs and using tools like the stately.ai editor for visualizing state machines.
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Watch video: Speeding Up Your React App With Less JavaScript
Mishko, the creator of Angular and AngularJS, discusses the challenges of website performance and JavaScript hydration. He explains the differences between client-side and server-side rendering and introduces Quik as a solution for efficient component hydration. Mishko demonstrates examples of state management and intercommunication using Quik. He highlights the performance benefits of using Quik with React and emphasizes the importance of reducing JavaScript size for better performance. Finally, he mentions the use of QUIC in both MPA and SPA applications for improved startup performance.

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured Workshop
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Next.js for React.js Developers
React Day Berlin 2023React Day Berlin 2023
157 min
Next.js for React.js Developers
Top Content
Featured WorkshopFree
Adrian Hajdin
Adrian Hajdin
In this advanced Next.js workshop, we will delve into key concepts and techniques that empower React.js developers to harness the full potential of Next.js. We will explore advanced topics and hands-on practices, equipping you with the skills needed to build high-performance web applications and make informed architectural decisions.
By the end of this workshop, you will be able to:1. Understand the benefits of React Server Components and their role in building interactive, server-rendered React applications.2. Differentiate between Edge and Node.js runtime in Next.js and know when to use each based on your project's requirements.3. Explore advanced Server-Side Rendering (SSR) techniques, including streaming, parallel vs. sequential fetching, and data synchronization.4. Implement caching strategies for enhanced performance and reduced server load in Next.js applications.5. Utilize React Actions to handle complex server mutation.6. Optimize your Next.js applications for SEO, social sharing, and overall performance to improve discoverability and user engagement.
Concurrent Rendering Adventures in React 18
React Advanced 2021React Advanced 2021
132 min
Concurrent Rendering Adventures in React 18
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
With the release of React 18 we finally get the long awaited concurrent rendering. But how is that going to affect your application? What are the benefits of concurrent rendering in React? What do you need to do to switch to concurrent rendering when you upgrade to React 18? And what if you don’t want or can’t use concurrent rendering yet?

There are some behavior changes you need to be aware of! In this workshop we will cover all of those subjects and more.

Join me with your laptop in this interactive workshop. You will see how easy it is to switch to concurrent rendering in your React application. You will learn all about concurrent rendering, SuspenseList, the startTransition API and more.
React Hooks Tips Only the Pros Know
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
Introducing FlashList: Let's build a performant React Native list all together
React Advanced 2022React Advanced 2022
81 min
Introducing FlashList: Let's build a performant React Native list all together
Top Content
Featured Workshop
David Cortés Fulla
Marek Fořt
Talha Naqvi
3 authors
In this workshop you’ll learn why we created FlashList at Shopify and how you can use it in your code today. We will show you how to take a list that is not performant in FlatList and make it performant using FlashList with minimum effort. We will use tools like Flipper, our own benchmarking code, and teach you how the FlashList API can cover more complex use cases and still keep a top-notch performance.You will know:- Quick presentation about what FlashList, why we built, etc.- Migrating from FlatList to FlashList- Teaching how to write a performant list- Utilizing the tools provided by FlashList library (mainly the useBenchmark hook)- Using the Flipper plugins (flame graph, our lists profiler, UI & JS FPS profiler, etc.)- Optimizing performance of FlashList by using more advanced props like `getType`- 5-6 sample tasks where we’ll uncover and fix issues together- Q&A with Shopify team
React, TypeScript, and TDD
React Advanced 2021React Advanced 2021
174 min
React, TypeScript, and TDD
Top Content
Featured Workshop
Paul Everitt
Paul Everitt
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.

The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.

React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.