Gathering detailed insights and metrics for @remix-run/router
Gathering detailed insights and metrics for @remix-run/router
Gathering detailed insights and metrics for @remix-run/router
Gathering detailed insights and metrics for @remix-run/router
npm install @remix-run/router
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.9
Supply Chain
99.6
Quality
87.6
Maintenance
100
Vulnerability
100
License
TypeScript (98.94%)
JavaScript (0.66%)
CSS (0.34%)
Shell (0.06%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
55,187 Stars
9,883 Commits
10,651 Forks
805 Watchers
36 Branches
1,076 Contributors
Updated on Jul 12, 2025
Latest Version
1.23.0
Package Id
@remix-run/router@1.23.0
Unpacked Size
2.62 MB
Size
669.13 kB
File Count
20
NPM Version
10.8.2
Node Version
20.18.3
Published on
Feb 27, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
The @remix-run/router
package is a framework-agnostic routing package (sometimes referred to as a browser-emulator) that serves as the heart of React Router and Remix and provides all the core functionality for routing coupled with data loading and data mutations. It comes with built-in handling of errors, race-conditions, interruptions, cancellations, lazy-loading data, and much, much more.
If you're using React Router, you should never import
anything directly from the @remix-run/router
- you should have everything you need in react-router-dom
(or react-router
/react-router-native
if you're not rendering in the browser). All of those packages should re-export everything you would otherwise need from @remix-run/router
.
[!WARNING]
This router is a low-level package intended to be consumed by UI layer routing libraries. You should very likely not be using this package directly unless you are authoring a routing library such as
react-router-dom
or one of it's other UI ports.
A Router instance can be created using createRouter
:
1// Create and initialize a router. "initialize" contains all side effects 2// including history listeners and kicking off the initial data fetch 3let router = createRouter({ 4 // Required properties 5 routes: [{ 6 path: '/', 7 loader: ({ request, params }) => { /* ... */ }, 8 children: [{ 9 path: 'home', 10 loader: ({ request, params }) => { /* ... */ }, 11 }] 12 }, 13 history: createBrowserHistory(), 14 15 // Optional properties 16 basename, // Base path 17 mapRouteProperties, // Map framework-agnostic routes to framework-aware routes 18 future, // Future flags 19 hydrationData, // Hydration data if using server-side-rendering 20}).initialize();
Internally, the Router represents the state in an object of the following format, which is available through router.state
. You can also register a subscriber of the signature (state: RouterState) => void
to execute when the state updates via router.subscribe()
;
1interface RouterState { 2 // False during the initial data load, true once we have our initial data 3 initialized: boolean; 4 // The `history` action of the most recently completed navigation 5 historyAction: Action; 6 // The current location of the router. During a navigation this reflects 7 // the "old" location and is updated upon completion of the navigation 8 location: Location; 9 // The current set of route matches 10 matches: DataRouteMatch[]; 11 // The state of the current navigation 12 navigation: Navigation; 13 // The state of any in-progress router.revalidate() calls 14 revalidation: RevalidationState; 15 // Data from the loaders for the current matches 16 loaderData: RouteData; 17 // Data from the action for the current matches 18 actionData: RouteData | null; 19 // Errors thrown from loaders/actions for the current matches 20 errors: RouteData | null; 21 // Map of all active fetchers 22 fetchers: Map<string, Fetcher>; 23 // Scroll position to restore to for the active Location, false if we 24 // should not restore, or null if we don't have a saved position 25 // Note: must be enabled via router.enableScrollRestoration() 26 restoreScrollPosition: number | false | null; 27 // Proxied `preventScrollReset` value passed to router.navigate() 28 preventScrollReset: boolean; 29}
All navigations are done through the router.navigate
API which is overloaded to support different types of navigations:
1// Link navigation (pushes onto the history stack by default) 2router.navigate("/page"); 3 4// Link navigation (replacing the history stack) 5router.navigate("/page", { replace: true }); 6 7// Pop navigation (moving backward/forward in the history stack) 8router.navigate(-1); 9 10// Form submission navigation 11let formData = new FormData(); 12formData.append(key, value); 13router.navigate("/page", { 14 formMethod: "post", 15 formData, 16}); 17 18// Relative routing from a source routeId 19router.navigate("../../somewhere", { 20 fromRouteId: "active-route-id", 21});
Fetchers are a mechanism to call loaders/actions without triggering a navigation, and are done through the router.fetch()
API. All fetch calls require a unique key to identify the fetcher.
1// Execute the loader for /page 2router.fetch("key", "/page"); 3 4// Submit to the action for /page 5let formData = new FormData(); 6formData.append(key, value); 7router.fetch("key", "/page", { 8 formMethod: "post", 9 formData, 10});
By default, active loaders will revalidate after any navigation or fetcher mutation. If you need to kick off a revalidation for other use-cases, you can use router.revalidate()
to re-execute all active loaders.
We use Future Flags in the router to help us introduce breaking changes in an opt-in fashion ahead of major releases. Please check out the blog post and React Router Docs for more information on this process. The currently available future flags in @remix-run/router
are:
Flag | Description |
---|---|
v7_normalizeFormMethod | Normalize useNavigation().formMethod to be an uppercase HTTP Method |
v7_prependBasename | Prepend the basename to incoming router.navigate /router.fetch paths |
No vulnerabilities found.
Reason
30 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
dangerous workflow patterns detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
41 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More