Gathering detailed insights and metrics for connected-next-router
Gathering detailed insights and metrics for connected-next-router
Gathering detailed insights and metrics for connected-next-router
Gathering detailed insights and metrics for connected-next-router
npm install connected-next-router
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
109 Stars
148 Commits
30 Forks
6 Watching
16 Branches
7 Contributors
Updated on 24 Jun 2024
TypeScript (76.56%)
JavaScript (23.44%)
Cumulative downloads
Total Downloads
Last day
-19.8%
1,542
Compared to previous day
Last week
3.5%
8,469
Compared to previous week
Last month
13.9%
34,220
Compared to previous month
Last year
-1.4%
301,061
Compared to previous year
4
23
v5.0.0 requires Next.js 10 or newer, React Redux 7.1.0 or newer, and React 16.8.0 or newer. If you are using Next.js 9, check out v3 branch. If you are using Next.js 7-8, check out v0 branch.
A Redux binding for Next.js Router compatible with Next.js.
:sparkles: Keep Router state in sync with your Redux store.
:tada: Dispatch Router methods (push
, replace
, go
, goBack
, goForward
, prefetch
) using Redux actions.
:clock9: Support time traveling in Redux DevTools.
:gem: Ease migration to next.js framework from codebases using connected-react-router or react-router-redux (see migration guide).
Using npm:
$ npm install --save connected-next-router
Or yarn:
$ yarn add connected-next-router
routerReducer
to your root reducer.createRouterMiddleware
if you want to dispatch Router actions (ex. to change URL with push('/home')
).initialRouterState(url)
to populate router state in the server side.1// store/configure-store.js 2import { createStore, applyMiddleware, combineReducers } from 'redux' 3import { createRouterMiddleware, initialRouterState, routerReducer } from 'connected-next-router' 4import { HYDRATE, createWrapper } from 'next-redux-wrapper' 5import Router from 'next/router' 6 7const rootReducer = combineReducers({ 8 // Add other reducers 9 router: routerReducer 10}); 11 12const routerMiddleware = createRouterMiddleware(); 13 14// Using next-redux-wrapper's initStore 15const reducer = (state, action) => { 16 if (action.type === HYDRATE) { 17 const nextState = { 18 ...state, // use previous state 19 ...action.payload, // apply delta from hydration 20 } 21 if (typeof window !== 'undefined' && state?.router) { 22 // preserve router value on client side navigation 23 nextState.router = state.router 24 } 25 return nextState 26 } else { 27 return rootReducer(state, action) 28 } 29} 30 31export const initStore = (context) => { 32 const routerMiddleware = createRouterMiddleware() 33 const { asPath } = context.ctx || Router.router || {} 34 let initialState 35 if (asPath) { 36 initialState = { 37 router: initialRouterState(asPath) 38 } 39 } 40 return createStore(reducer, initialState, applyMiddleware(routerMiddleware)) 41} 42 43export const wrapper = createWrapper(initStore)
ConnectedRouter
as children of react-redux
's Provider
.1// pages/_app.js 2import App from 'next/app' 3import { ConnectedRouter } from 'connected-next-router' 4import { wrapper } from '../store/configure-store' 5 6class ExampleApp extends App { 7 render() { 8 const { Component, pageProps } = this.props 9 return ( 10 <ConnectedRouter> 11 <Component {...pageProps} /> 12 </ConnectedRouter> 13 ) 14 } 15} 16 17// wrapper.withRedux wraps the App with react-redux's Provider 18export default wrapper.withRedux(ExampleApp)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/11 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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