Skip to content

HMR evaluates multiple times #13774

Open
Open
@idoros

Description

@idoros

I'm using React Router as a...

framework

Reproduction

  1. either create a new React Router project from a template or go to this newly created stackblitz
  2. open app/routes/home.tsx
  3. modify the code (no new exports or imports)
  4. check the HMR logs. You should see the message [vite] hot updated: /app/routes/home.tsx being triggered multiple times

Observations:

  • disabling SSR appears to reduce the number of updates to just 2.
  • this issue occurs also when modifying a component, not a route specifically.
  • when adding a console log to the modified file, it’s clear that the module is being re-evaluated multiple times.
  • for some reason, /app/app.css is being updated as well, even though it is unrelated to the changed module.
  • this issue doesn’t occur when using standalone Vite.

Image

System Info

Binaries:
    Node: 23.11.0 - ~/.nvm/versions/node/v23.11.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v23.11.0/bin/npm
  npmPackages:
    @react-router/dev: ^7.5.3 => 7.6.2 
    @react-router/node: ^7.5.3 => 7.6.2 
    @react-router/serve: ^7.5.3 => 7.6.2 
    react-router: ^7.5.3 => 7.6.2 
    vite: ^6.3.3 => 6.3.5

Used Package Manager

npm

Expected Behavior

HMR updates with minimal evaluations

Actual Behavior

  • re-evaluated multiple times (2–3)
  • HMR is also triggered for an unrelated CSS module

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions