>**Goodtoknow:**Use[`useRouter().bfcacheId`](/docs/app/api-reference/functions/use-router#bfcacheid) as a [React `key`](https://react.dev/learn/preserving-and-resetting-state#option-2-resetting-state-with-a-key): a single `<Fragment key={bfcacheId}>` resets an entire subtree on push or replace navigations (including `<Link>` clicks and `router.push` / `router.replace`) while still restoring state on browser back/forward. `bfcacheId` is mainly a migration tool. For new code, prefer the per-pattern resets below.
>**Goodtoknow:**Use[`useRouter().bfcacheId`](/docs/app/api-reference/functions/use-router#bfcacheid) as a [React `key`](https://react.dev/learn/preserving-and-resetting-state#option-2-resetting-state-with-a-key): a single `<Fragment key={bfcacheId}>` resets an entire subtree on push or replace navigations (including `<Link>` clicks and `router.push` / `router.replace`) while still restoring state on browser back/forward. It is not a complete opt-out from state preservation. `bfcacheId` is mainly a migration tool. For new code, prefer the per-pattern resets below.
When the component becomes visible again, effects re-run and playback position is preserved since the DOM node was never removed.
When the component becomes visible again, effects re-run and playback position is preserved since the DOM node was never removed.
### Imperative canvas, map, and editor libraries
Libraries that own DOM state outside React need an explicit hide/show strategy. A map, diagram editor, chart, or canvas may measure its container while it is visible and keep those dimensions internally. Activity preserves that DOM while hiding its container with `display: none`, so the library may need to recalculate its viewport when the route becomes visible again.
For libraries that are inexpensive to initialize, the simplest migration is to create the instance in a layout Effect and destroy it in the cleanup. Activity runs that cleanup when the route is hidden and runs the Effect again when it is shown:
If recreating the instance is too expensive, keep it in a ref, pause subscriptions in the cleanup, and call the library'sresizeorviewportmethodwhenthelayoutEffectrunsagain.Testbothreturningthroughalinkandbrowserback/forwardbecausebothpathscanrestorepreservedUI.
Enabling Cache Components also changes client-side navigation lifecycle. Recently visited routes are hidden with React [`<Activity>`](https://react.dev/reference/react/Activity) instead of being unmounted, so component state, form values, refs, and scroll position can be restored when the user returns.
Before shipping, audit UI that previously relied on unmounting to reset: dialogs, popovers, form status, timers, subscriptions, and imperative canvas, map, or editor libraries. Effects clean up when a route is hidden and run again when it becomes visible, but React and DOM state remain.
[`useRouter().bfcacheId`](/docs/app/api-reference/functions/use-router#bfcacheid) can key a subtree so push and replace navigations start with fresh state. It is not a complete return to the previous behavior because browser back and forward navigation deliberately restores the earlier state. See [Preserving UI state across navigations](/docs/app/guides/preserving-ui-state) for migration patterns and testing guidance.
PPR in **Next.js 16** works differently than in **Next.js 15** canaries. If you are using PPR today, stay in the current Next.js 15 canary you are using. See [Migrating to Cache Components](/docs/app/guides/migrating-to-cache-components) for migration patterns.
PPR in **Next.js 16** works differently than in **Next.js 15** canaries. If you are using PPR today, stay in the current Next.js 15 canary you are using. See [Migrating to Cache Components](/docs/app/guides/migrating-to-cache-components) for migration patterns.