Skip to content

React Router v7 library mode with createBrowserRouter doesn't re-render on file changes in Vite HMR #13159

Open
@alanko0511

Description

@alanko0511

I'm using React Router as a...

library

Reproduction

https://stackblitz.com/edit/vitejs-vite-ry7qt74n?file=src%2Froutes%2FIndexPage.tsx

Change the div text in the src/routes/IndexPage.tsx file, the page doesn't re-render. However, if I downgrade the React Router package version to 7.1.3, it will re-render as expected.

I saw that the Vite HMR WebSocket receives the file changes and downloads the file correctly when I test it locally, so I believe Vite is working as expected.

System Info

System:
    OS: macOS 13.0
    CPU: (12) arm64 Apple M2 Pro
    Memory: 74.41 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 23.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
    pnpm: 9.4.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.142
    Safari: 16.1
  npmPackages:
    react-router: ^7.2.0 => 7.2.0 
    vite: ^6.2.0 => 6.2.0

Used Package Manager

pnpm

Expected Behavior

The page should be re-rendered when I change an element in the demo's src/routes/IndexPage.tsx file.

Actual Behavior

The changes I made don't cause it to re-render.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions