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 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.

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.

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

Routing in React 18 and Beyond
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Top Content
Routing in React 18 brings a native app-like user experience and allows applications to transition between different environments. React Router and Next.js have different approaches to routing, with React Router using component-based routing and Next.js using file system-based routing. React server components provide the primitives to address the disadvantages of multipage applications while maintaining the same user experience. Improving navigation and routing in React involves including loading UI, pre-rendering parts of the screen, and using server components for more performant experiences. Next.js and Remix are moving towards a converging solution by combining component-based routing with file system routing.
A Practical Guide for Migrating to Server Components
React Advanced 2023React Advanced 2023
28 min
A Practical Guide for Migrating to Server Components
Top Content
Watch video: A Practical Guide for Migrating to Server Components
React query version five is live and we'll be discussing the migration process to server components using Next.js and React Query. The process involves planning, preparing, and setting up server components, migrating pages, adding layouts, and moving components to the server. We'll also explore the benefits of server components such as reducing JavaScript shipping, enabling powerful caching, and leveraging the features of the app router. Additionally, we'll cover topics like handling authentication, rendering in server components, and the impact on server load and costs.
The New Next.js App Router
React Summit 2023React Summit 2023
27 min
The New Next.js App Router
Top Content
Watch video: The New Next.js App Router
Today's Talk is about the Next.js App Router, which has evolved over the years and is now a core feature of Next.js. The Talk covers topics such as adding components, fetching remote data, and exploring layouts. It also discusses submitting form data, simplifying code, and reusing components. The App Router allows for coexistence with the existing pages router and enables data fetching at the layout level using React Server Components.
You Don’t Know How to SSR
DevOps.js Conf 2024DevOps.js Conf 2024
23 min
You Don’t Know How to SSR
The Talk covers the speaker's personal journey into server-side rendering (SSR) and the evolution of web development frameworks. It explores the use of jQuery for animations in SSR, the challenges faced in integrating React with Umbraco, and the creation of a custom SSR framework. The Talk also discusses the benefits of Next.js and the use of serverless artifacts for deployment. Finally, it highlights the features of Astro, including its function per route capability.
How to properly handle URL slug changes in Next.js
TypeScript Congress 2022TypeScript Congress 2022
10 min
How to properly handle URL slug changes in Next.js
Top Content
This Talk explains how to handle URL slug changes in Next.js by using the getStaticPaths and getStaticProps methods. It covers implementing redirects and provides a solution to eliminate the need for editors to perform additional steps. The approach involves tracking URL slug changes and issuing proper redirects. The speaker encourages the audience to reach out with any questions or experiences with handling URL slugs.
Killing BFFs with GraphQL and Next.js
React Advanced 2021React Advanced 2021
21 min
Killing BFFs with GraphQL and Next.js
Top Content
This talk discusses the challenges and benefits of using Backend for Frontends (BFFs) and microservices in software development. It highlights how Next.js can simplify the creation of BFFs and unify the gateway for microservices. The talk also emphasizes the advantages of Next.js API routes in simplifying the development, deployment, and maintenance of APIs. It showcases the implementation of a BFF using Next.js and API routes, and the extension of API routes in an executable way. The speaker also mentions launching a course on using Next.js API routes for building a serverless GraphQL API.

Workshops on related topic

AI for React Developers
React Advanced 2024React Advanced 2024
142 min
AI for React Developers
Top Content
Featured Workshop
Eve Porcello
Eve Porcello
Knowledge of AI tooling is critical for future-proofing the careers of React developers, and the Vercel suite of AI tools is an approachable on-ramp. In this course, we’ll take a closer look at the Vercel AI SDK and how this can help React developers build streaming interfaces with JavaScript and Next.js. We’ll also incorporate additional 3rd party APIs to build and deploy a music visualization app.
Topics:- Creating a React Project with Next.js- Choosing a LLM- Customizing Streaming Interfaces- Building Routes- Creating and Generating Components - Using Hooks (useChat, useCompletion, useActions, etc)
Tracing: Frontend Issues With Backend Solutions
React Summit US 2024React Summit US 2024
112 min
Tracing: Frontend Issues With Backend Solutions
Top Content
Featured WorkshopFree
Lazar Nikolov
Sarah Guthals
2 authors
Frontend issues that affect your users are often triggered by backend problems. In this workshop, you’ll learn how to identify issues causing slow web pages and poor Core Web Vitals using tracing.
Then, try it for yourself by setting up Sentry in a ready-made Next.js project to discover performance issues including slow database queries in an interactive pair-programming session.
You’ll leave the workshop being able to:- Find backend issues that might be slowing down your frontend apps- Setup tracing with Sentry in a Next.js project- Debug and fix poor performance issues using tracing
This will be a live 2-hour event where you’ll have the opportunity to code along with us and ask us questions.
From Frontend to Fullstack Development With Next.js
React Summit 2025React Summit 2025
91 min
From Frontend to Fullstack Development With Next.js
Featured Workshop
Eric Burel
Eric Burel
Join us as we journey from React frontend development to fullstack development with Next.js. During this workshop, we'll follow along the official Next.js Learn tutorial with Eric Burel, professional trainer and author of NextPatterns.dev. Together, we'll set up a Next.js website and explore its server-side features to build performant apps.
Build a Headless WordPress App with Next.js and WPGraphQL
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
Workshop
Kellen Mace
Kellen Mace
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
Workshop
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
From Todo App to B2B SaaS with Next.js and Clerk
React Summit US 2023React Summit US 2023
153 min
From Todo App to B2B SaaS with Next.js and Clerk
Top Content
WorkshopFree
Dev Agrawal
Dev Agrawal
If you’re like me, you probably have a million side-project ideas, some that could even make you money as a micro SaaS, or could turn out to be the next billion dollar startup. But how do you know which ones? How do you go from an idea into a functioning product that can be put into the hands of paying customers without quitting your job and sinking all of your time and investment into it? How can your solo side-projects compete with applications built by enormous teams and large enterprise companies?
Building rich SaaS products comes with technical challenges like infrastructure, scaling, availability, security, and complicated subsystems like auth and payments. This is why it’s often the already established tech giants who can reasonably build and operate products like that. However, a new generation of devtools are enabling us developers to easily build complete solutions that take advantage of the best cloud infrastructure available, and offer an experience that allows you to rapidly iterate on your ideas for a low cost of $0. They take all the technical challenges of building and operating software products away from you so that you only have to spend your time building the features that your users want, giving you a reasonable chance to compete against the market by staying incredibly agile and responsive to the needs of users.
In this 3 hour workshop you will start with a simple task management application built with React and Next.js and turn it into a scalable and fully functioning SaaS product by integrating a scalable database (PlanetScale), multi-tenant authentication (Clerk), and subscription based payments (Stripe). You will also learn how the principles of agile software development and domain driven design can help you build products quickly and cost-efficiently, and compete with existing solutions.