How to disable client-side <Activity> (Keep Alive) behavior when using "use cache" in Next.js 16? #87110
-
SummaryI am experimenting with Next.js 16 and React 19, specifically utilizing the new The Problem While I understand this is likely for "Instant Back" navigation, it is breaking my application's styling. Because the previous page remains in the DOM:
What I need help with
Additional information**Context:**
* **Next.js Version:** 16
* **React Version:** 19
* **Features Enabled:** `use cache`ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Isn't this just the problem with global page level styles? I mean, it likely happens without Cache Components too.
Got any example for this? I know before, tooltips used via Portals had issues, but that's been fixed on React itself. Cuz when Activity hides DOM elements it removes them from the document flow via display: none, but I am sure there might be some edge case. I'd like to see a clear example.
You could clean up on useLayoutEffect for those cases, right? or? I shall also add that the team is aware of the feedback around this topic. |
Beta Was this translation helpful? Give feedback.
Warning
As part of v16 and Cache Components, the documentation for
experimental.useCachewas removed, but the configuration flag remained in place. It was kept to help with migration intoCache Components. If you do decide to use it at this point, do remember that because it is bothundocumentedandexperimental, it could be removed in the future. It is advised to try to migrate toCache Components.I explored the code and found that
useCacheseems to be the main flag. I also noticed references tocacheComponent.Is the following configuration the correct way to keep the cache features enabled (
useCache) but opt-out of the client-side Compo…