Skip to content

"use cache"'d components do not update during HMR inside an iFrame #90143

@rikbrown

Description

@rikbrown

Link to the code that reproduces this issue

https://github.com/rikbrown/nextjs-use-cache-in-iframe-hmr

To Reproduce

  1. Start the application in dev mode, go directly to URL.
  2. Make changes in the CacheComponent component in page.tsx, observe HMR.
  3. Now go to the page in an iFrame (either a local html file or remote - I put one in the repo)
  4. Make changes, observe no HMR
  5. HARD refresh, observe updated value,
  6. Make changes, observe no HMR.

Current vs. Expected behavior

HMR should occur without needing a hard refresh.

Provide environment information

bun next info

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041
  Available memory (MB): 131072
  Available CPU cores: 16
Binaries:
  Node: 22.18.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.28.2
Relevant Packages:
  next: 16.2.0-canary.50 // Latest available version is detected (16.2.0-canary.50).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Use Cache

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Tested on latest stable and canary.

Tested w/ "allow third party cookies off".

Verified if I manually disable caches in the chrome dev tools, HMR does work.

The crazy thing to me is if I then open the iFrame in a totally different browser, it is still out of date. But opening the exact same URL, just not in an iframe, is up to date. This is beyond my comprehension of how Next.js caches things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions