Multiple issues after migrating to Cache Components #89160
Replies: 1 comment 4 replies
-
|
This is because with Cache Components activated, Next.js wraps routes in React's Activity Boundaries.
This keeps a number of routes (3) around, in the DOM, in React's new hidden mode (so-to-speak). More info in the Next.js docs. This issue is tracking feedback, workarounds, and more info, including likely upcoming changes: Furthermore we have an upcoming Activity guide: #89126 I'd say first understand what Activity is doing, from a pure React point of view, and then you can identify some way forward, or wait a bit until the gradual migration path lands. An official way forward is gaining traction, but as long as it is not published, it is best to work with what's available at the moment. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have an application running on the latest Next.js (v16), which works perfectly under normal conditions. However, after migrating to Cache Components, I started encountering multiple issues—even though I’ve followed all the required cache component rules.
One specific issue I’m reporting here is that a form fails to re-render correctly when navigating between routes via
<Link>.🔗 Reproduction Repository
https://github.com/abhishekmardiya/cache-components-issues
🔁 Reproduction Steps
/test-2)./test-1).At this point, you’ll notice that the default value is no longer restored in the form input as you move back and forth between these two routes.
✅ Expected Behavior
The form should re-render and display the default input value every time the route changes.
❌ Actual Behavior
The input retains the previously cleared state, and the default value is not restored when navigating back.
📝 Additional Notes
According to this documentation:
https://nextjs.org/docs/app/getting-started/cache-components#navigation-uses-activity
When the cacheComponents flag is enabled, Next.js uses React’s
<Activity>component to preserve component state during client-side navigation.Is there a way to override this behavior? In our case, this causes unintended results because the component state is preserved and the page does not re-render as expected during navigation.
Being able to opt out of this behavior (or force a re-render) would help avoid these issues.
Environment Information
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:34 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8112
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 24.13.0
npm: 11.6.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.1.6 // Latest available version is detected (16.1.6).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
Could someone please explain why this happens with Cache Components enabled? Understanding this behavior would help me identify the correct fix.
@icyJoseph
With cache components
with-cc.mov
Without cache components
without-cc.mov
Beta Was this translation helpful? Give feedback.
All reactions