Skip to content

feat!: support React Router v8 in the react-router preset - #625

Open
antfu wants to merge 2 commits into
mainfrom
feat/react-router-v8-preset
Open

feat!: support React Router v8 in the react-router preset#625
antfu wants to merge 2 commits into
mainfrom
feat/react-router-v8-preset

Conversation

@antfu

@antfu antfu commented Aug 3, 2026

Copy link
Copy Markdown
Member

Why

react-router-dom has no v8 — the package was removed in that major and everything it exported moved into react-router itself. The react-router preset only lists the v6 hooks, so on v8 it no longer covers the components and hooks users actually need.

Split out of the dependency-update sweep on main because it is a breaking change to a shipped preset.

What

Extracts the names that used to be react-router-dom-only into ReactRouterDomExports and spreads them into both presets. The react-router preset now also covers:

Link · NavLink · Navigate · Outlet · Route · Routes · useSearchParams · useLinkClickHandler

BrowserRouter / HashRouter / MemoryRouter stay commented out, as before — they are called once and are not a good fit for auto-import.

The vite-react example is migrated onto react-router v8: react-router-dom dropped from its dependencies, BrowserRouter imported from react-router, and the preset name updated in its vite.config.ts.

The react-router-dom preset is kept

It is not removed, and its resolved import list is byte-identical to before — only its construction changed, so it now shares the two extracted arrays. v6 and v7 users who use that preset are unaffected.

It carries a @deprecated tag recording that the package is gone in v8 and pointing at the react-router preset. Note this is source-level documentation: presets are bundled internals, so the tag does not reach the published .d.mts, and the public PresetName string union cannot carry per-member deprecation. README already points readers at src/presets directly.

⚠️ Breaking

The react-router preset's output is unconditional — it always returns the v8 list. Those names are not on react-router's main entry in v6 or v7, so consumers on those majors who use the react-router preset will get generated imports that do not resolve.

Migration: switch to the react-router-dom preset, which is unchanged.

This was a deliberate choice over making react-router a version-aware function preset (which the codebase supports — see @vueuse/core): keeping the output static means preset results stay predictable and independent of install state.

Verification

build, typecheck, lint and all 41 tests pass. Every example and the playground build, including tsc && vite build for vite-react.

🤖 Generated with Claude Code

react-router-dom has no v8 — the package was removed and everything it
exported moved into react-router. Extract the shared names into
ReactRouterDomExports and spread them into both presets, so the
react-router preset now also covers Link, NavLink, Navigate, Outlet,
Route, Routes, useSearchParams and useLinkClickHandler.

BREAKING CHANGE: those names are not on react-router's main entry in v6
or v7, so the react-router preset now generates imports that do not
resolve for consumers still on those majors. They should use the
react-router-dom preset, whose contents are unchanged.

Migrates the vite-react example onto react-router v8 accordingly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@socket-security

socket-security Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedreact-router@​8.3.0731007996100

View full report

@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-auto-import@625

commit: da057ee

The preset stays and its resolved list is unchanged, so v6 and v7 users
keep working. The tag records that the package is gone in v8 and points
at the react-router preset.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant