Fork and modernize React Router v5 for our own usage
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, react, typescript
調査の方向性
Start by reading the current React Router v5 packages and Docusaurus routing entry points; the issue names no specific files or tests. The proposed first step is to vendor the packages and switch @docusaurus/core with no behavior change, checking tests, the website build diff, and Argos. Completion spans removing unused APIs and dependencies, adding TypeScript types, and verifying compatibility with the listed Docusaurus and plugin APIs.
索引モデルが issue の本文から書いたものです。
説明
Motivation
Docusaurus runs on React Router v5 (react-router and react-router-dom 5.3.4, react-router-config 5.1.1, history 4.10.1), and we plan to stay on it: upgrading is too disruptive for our ecosystem and would increase the weight of a Docusaurus site (see https://github.com/meta/docusaurus/issues/11719 and https://github.com/meta/docusaurus/pull/12201#issuecomment-6504253771).
But v5 is frozen: its last release is 5.3.4 from October 2022, and React Router's security policy lists "6.x and below" as unsupported. It also carries a lot of legacy we don't need: Browserify transforms, a createContext polyfill for React < 16.3, propTypes, Babel helpers, CommonJS-first builds and community types from DefinitelyTyped.
We'd like to fork it in the monorepo, clean it up and modernize it for our own usage, and remove the parts we don't need.
No known v5 vulnerability
This is not a security fix. As of November 2026, no published advisory affects React Router v5 code:
- The React Router security advisories (about 30, up to November 18, 2026) all target 6.x, 7.x or 8.x. Most are about data/framework mode, SSR, single fetch and RSC, which don't exist in v5.
- The GitHub Advisory Database and OSV return no advisory for the exact versions we install.
The transitive dependencies are clean too:
| Package | Version | Advisories |
|---|---|---|
path-to-regexp |
1.9.0 | CVE-2024-45296 (ReDoS) affects <1.9.0, fixed in the version we install. The 2026 CVEs only affect 0.1.x and 8.x |
@babel/runtime |
7.29.7 | CVE-2025-27789 affects <7.26.10, fixed in the version we install |
history, resolve-pathname, value-equal, hoist-non-react-statics, prop-types, object-assign, react-is, loose-envify, js-tokens, tiny-invariant, tiny-warning, isarray |
None, ever |
The risk is about the future: if a v5 vulnerability is found, nobody will publish a fix. Owning the code means we can.
What we use
Official packages
| Package | APIs |
|---|---|
react-router-dom |
BrowserRouter, HashRouter (future.experimental_router: 'hash'), StaticRouter (SSR), Route (PendingNavigation), Link, NavLink (@docusaurus/Link), Redirect, matchPath, useHistory, useLocation. MemoryRouter in tests only |
react-router-config |
matchRoutes (client and the broken links checker), renderRoutes |
history |
Types (Location, History, Action) and the history object: push, replace, listen, block, location |
Our public API re-exports a subset: @docusaurus/router exports useHistory, useLocation, Redirect and matchPath, @docusaurus/Link wraps Link/NavLink, and @docusaurus/renderRoutes re-exports renderRoutes. The Location type of history is part of @docusaurus/types (onRouteUpdate).
Third-party plugins
I checked the latest release of the 20 most downloaded third-party plugins and themes (by npm weekly downloads). None imports react-router, react-router-dom, react-router-config or history directly, and none declares them as a dependency. The 6 that do routing all use @docusaurus/router:
| Plugin | Weekly downloads | Usage |
|---|---|---|
@easyops-cn/docusaurus-search-local |
562k | useHistory, useLocation: push, replace, reads pathname/search/hash |
docusaurus-theme-openapi-docs |
149k | useHistory: listen, location, replace |
docusaurus-lunr-search |
117k | useHistory, useLocation: push(url, state) and location.state |
@cmfcmf/docusaurus-search-local |
45k | useHistory, useLocation: push(url, state) and location.state |
docusaurus-theme-search-typesense |
17k | useHistory, useLocation: push, replace, reads search |
@conduction/docusaurus-preset |
7.7k | useLocation: reads pathname |
The other 14 have no routing code: docusaurus-plugin-sass, docusaurus-plugin-openapi-docs, docusaurus-plugin-image-zoom, docusaurus-theme-redoc, redocusaurus, docusaurus-plugin-redoc, docusaurus-plugin-typedoc, docusaurus-plugin-llms, @signalwire/docusaurus-plugin-llms-txt, @scalar/docusaurus, @graphql-markdown/docusaurus, @r74tech/docusaurus-plugin-panzoom, docusaurus-plugin-mcp-server, docusaurus-plugin-copy-page-button. The ones that render links use @docusaurus/Link with string to values only.
The only feature they use that official packages don't is the location state: two search plugins pass the search terms to highlight through history.push(url, state), then read and clear location.state. The fork must keep it.
What we don't use
Nothing in the official packages or these 20 plugins uses withRouter, Prompt, useParams, useRouteMatch, generatePath, Router, Switch (only used internally by renderRoutes), or the __RouterContext/__HistoryContext internals. These are candidates for removal.
Proposal
Fork the 4 packages into a single monorepo package (for example @docusaurus/react-router, available on npm) that only @docusaurus/core depends on, with:
- TypeScript source and built-in types, replacing
@types/react-router-dom,@types/react-router-configand@types/history. Today,@docusaurus/types,@docusaurus/module-type-aliases,@docusaurus/theme-commonand@docusaurus/plugin-content-docspublish them asdependencies. - ESM-only output with an
exportsmap.@docusaurus/corerequires Node>=26.13, so the broken links checker can stillrequire()it. - Zero runtime dependencies, with
reactas a peer:
| Dependency | Plan |
|---|---|
prop-types, object-assign, react-is |
Remove: React 19 ignores propTypes |
loose-envify, js-tokens |
Remove: only a Browserify transform ("browserify": {"transform": ["loose-envify"]}), never run by webpack/Rspack |
@babel/runtime |
Remove: compile for modern JS, no helpers |
tiny-invariant, tiny-warning |
Inline (about 35 lines) |
hoist-non-react-statics |
Remove with withRouter |
history 4, resolve-pathname, value-equal |
Vendor, keeping the location state and block/listen |
path-to-regexp 1.9.0 |
Vendor the 2 functions used by matchPath (a rewrite risks changing how plugin route paths match) |
- Only the APIs we use: remove the unused ones listed above, the
createContextpolyfill (miniCreateReactContext, 175 lines) and the deprecated CommonJS entry points.
The codebase is small: about 1,030 lines for react-router, 380 for react-router-dom, 55 for react-router-config, 920 for history, plus about 700 lines of community types. Most of the work is in the types and the verification, not in the code.
Possible steps
- Vendor the code as-is in a new package and switch
@docusaurus/coreto it, with no behavior change (tests, website build diff, Argos). - Remove the dependencies, the unused APIs and the legacy code, and publish ESM only.
- Convert to TypeScript with built-in types, port the upstream v5 test suites, and remove the
@types/*dependencies. - Later, modernize the implementation. For example,
Routersubscribes tohistoryin its constructor, which is unsafe with StrictMode and concurrent rendering:useSyncExternalStorewould fit better.
Breaking changes
Docusaurus would no longer install react-router, react-router-dom, react-router-config and history. Sites, swizzled components and plugins that import them directly today work only because they resolve the same copy as @docusaurus/core:
- Code relying on hoisting would fail to resolve these packages.
- Code installing its own copy would get a separate router context, so
useLocation()would crash at runtime.
They should use @docusaurus/router instead. The top 20 plugins already do, but we can't measure custom site code from npm.
Open questions
- Should we alias
react-router,react-router-domandreact-router-configto the fork in the bundler config? Missing exports would then fail at build time with a clear error instead of crashing at runtime, but we'd have to keep their module names around. - Public package, or internal to
@docusaurus/coreand only exposed through@docusaurus/router? Do we expose more APIs there (likeStaticRouter/MemoryRouterfor tests)? - Do we keep the
HistoryandLocationtypes compatible with@types/history4, so code typed against it keeps compiling? - Is the 4th step (hooks,
useSyncExternalStore) in scope for 5.0?
(AI-assisted)
- 主要言語
- TypeScript
- スター
- 66.6k
- フォーク
- 10.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
facebook/docusaurus のほかの issue
-
write heading ids modifies headings inside tilde and longer fenced code blocks対応中かも @VaibhavBajpaij が 6 日前に担当しました。 オープンbug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
facebook/docusaurus#13061 · コメント 1 件 ·
-
Auto-generated description drops the text between two colons in the first paragraph対応中かも @0z5a が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
facebook/docusaurus#13059 ·
-
Playground cards have inconsistent heights対応中かも @anishagrawal25 が 31 日前に担当しました。 オープンbug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
facebook/docusaurus#12739 · コメント 1 件 ·
-
Page title drops a trailing # from the heading, e.g. # Learn C# becomes "Learn C" (AI-assisted)対応中かも @saiyam-jain-dev が 19 日前に担当しました。 オープンbug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
facebook/docusaurus#12644 · コメント 1 件 ·
-
Firefox clips descenders in documentation sidebar labels on Windows対応中かも @xusnitdinov が 126 日前に担当しました。 オープンbug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
facebook/docusaurus#12299 ·
facebook/docusaurus の issue をすべて見る
似ている issue
-
The manager preset saves launch definitions without the required file and digest pair対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信