Gathering detailed insights and metrics for connected-react-router
Gathering detailed insights and metrics for connected-react-router
Gathering detailed insights and metrics for connected-react-router
Gathering detailed insights and metrics for connected-react-router
fusion-plugin-connected-react-router
The `fusion-plugin-connected-react-router` package provides plugin to integrate connected-react-router with your app.
connected-next-router
A Redux binding for Next.js Router
@banzai-inc/connected-react-router
A Redux binding for React Router v4 and v5
redux-first-history
Redux First History - Redux history binding support react-router - @reach/router - wouter
A Redux binding for React Router v4
npm install connected-react-router
Typescript
Module System
Node Version
NPM Version
88.7
Supply Chain
97.6
Quality
74.8
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
139,419,987
Last Day
11,246
Last Week
363,693
Last Month
1,488,789
Last Year
17,620,166
MIT License
4,711 Stars
485 Commits
592 Forks
42 Watchers
24 Branches
76 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
6.9.3
Package Id
connected-react-router@6.9.3
Unpacked Size
433.57 kB
Size
124.67 kB
File Count
40
NPM Version
6.13.7
Node Version
13.11.0
Cumulative downloads
Total Downloads
Last Day
-7%
11,246
Compared to previous day
Last Week
-5.6%
363,693
Compared to previous week
Last Month
5.4%
1,488,789
Compared to previous month
Last Year
-14.9%
17,620,166
Compared to previous year
5
38
2
Breaking change in v5.0.0! Please read How to migrate from v4 to v5/v6.
v6.0.0 requires React v16.4.0 and React Redux v6.0 / v7.0.
A Redux binding for React Router v4 and v5
:sparkles: Synchronize router state with redux store through uni-directional flow (i.e. history -> store -> router -> components).
:gift: Supports React Router v4 and v5.
:sunny: Supports functional component hot reloading while preserving state (with react-hot-reload).
:tada: Dispatching of history methods (push
, replace
, go
, goBack
, goForward
) works for both redux-thunk and redux-saga.
:snowman: Nested children can access routing state such as the current location directly with react-redux
's connect
.
:clock9: Supports time traveling in Redux DevTools.
:gem: Supports Immutable.js
:muscle: Supports TypeScript
Connected React Router requires React 16.4 and React Redux 6.0 or later.
npm install --save connected-react-router
Or
yarn add connected-react-router
In your root reducer file,
history
as an argument and returns a root reducer.router
reducer into root reducer by passing history
to connectRouter
.router
.1// reducers.js 2import { combineReducers } from 'redux' 3import { connectRouter } from 'connected-react-router' 4 5const createRootReducer = (history) => combineReducers({ 6 router: connectRouter(history), 7 ... // rest of your reducers 8}) 9export default createRootReducer
When creating a Redux store,
history
object.history
to the root reducer creator.routerMiddleware(history)
if you want to dispatch history actions (e.g. to change URL with push('/path/to/somewhere')
).1// configureStore.js 2... 3import { createBrowserHistory } from 'history' 4import { applyMiddleware, compose, createStore } from 'redux' 5import { routerMiddleware } from 'connected-react-router' 6import createRootReducer from './reducers' 7... 8export const history = createBrowserHistory() 9 10export default function configureStore(preloadedState) { 11 const store = createStore( 12 createRootReducer(history), // root reducer with router state 13 preloadedState, 14 compose( 15 applyMiddleware( 16 routerMiddleware(history), // for dispatching history actions 17 // ... other middlewares ... 18 ), 19 ), 20 ) 21 22 return store 23}
ConnectedRouter
and pass the history
object as a prop. Remember to delete any usage of BrowserRouter
or NativeRouter
as leaving this in will cause problems synchronising the state.ConnectedRouter
as a child of react-redux
's Provider
.StaticRouter
from react-router
on the server.1// index.js 2... 3import { Provider } from 'react-redux' 4import { Route, Switch } from 'react-router' // react-router v4/v5 5import { ConnectedRouter } from 'connected-react-router' 6import configureStore, { history } from './configureStore' 7... 8const store = configureStore(/* provide initial state if any */) 9 10ReactDOM.render( 11 <Provider store={store}> 12 <ConnectedRouter history={history}> { /* place ConnectedRouter under Provider */ } 13 <> { /* your usual react-router v4/v5 routing */ } 14 <Switch> 15 <Route exact path="/" render={() => (<div>Match</div>)} /> 16 <Route render={() => (<div>Miss</div>)} /> 17 </Switch> 18 </> 19 </ConnectedRouter> 20 </Provider>, 21 document.getElementById('react-root') 22)
Note: the history
object provided to router
reducer, routerMiddleware
, and ConnectedRouter
component must be the same history
object.
Now, it's ready to work!
See the examples folder
1npm run build
Generated files will be in the lib
folder.
When testing the example apps with npm link
or yarn link
, you should explicitly provide the same Context
to both Provider
and ConnectedRouter
to make sure that the ConnectedRouter
doesn't pick up a different ReactReduxContext
from a different node_modules
folder.
In index.js
.
1... 2import { Provider, ReactReduxContext } from 'react-redux' 3... 4 <Provider store={store} context={ReactReduxContext}> 5 <App history={history} context={ReactReduxContext} /> 6 </Provider> 7...
In App.js
,
1... 2const App = ({ history, context }) => { 3 return ( 4 <ConnectedRouter history={history} context={context}> 5 { routes } 6 </ConnectedRouter> 7 ) 8} 9...
See Contributors and Acknowledge.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 2/5 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
92 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
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