Gathering detailed insights and metrics for @cdmbase/redux-data-router
Gathering detailed insights and metrics for @cdmbase/redux-data-router
Control your React Router v6 data router with Redux
npm install @cdmbase/redux-data-router
Typescript
Module System
68.7
Supply Chain
98.7
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
5,180
Last Day
7
Last Week
77
Last Month
298
Last Year
4,806
12 Stars
9 Commits
1 Forks
2 Watchers
2 Branches
1 Contributors
Updated on Feb 10, 2025
Minified
Minified + Gzipped
Latest Version
1.0.10
Package Id
@cdmbase/redux-data-router@1.0.10
Unpacked Size
8.08 kB
Size
3.58 kB
File Count
8
Published on
Mar 12, 2024
Cumulative downloads
Total Downloads
Last Day
16.7%
7
Compared to previous day
Last Week
35.1%
77
Compared to previous week
Last Month
-17.9%
298
Compared to previous month
Last Year
1,185%
4,806
Compared to previous year
7
redux-data-router
🔩redux-data-router
is a clean-room spiritual successor to projects like
redux-first-history.
You only need to bring your React Router v6 data router
, no need to manage a history
object (or use UNSTABLE_
methods :smile:)
router
1import {createEnhancer, reducer} from 'redux-data-router';
2
3// Create your data router like normal.
4const router = createBrowserRouter(routes);
5// Install the router reducer and enhancer.
6const store = configureStore(
7 reducer: {router: reducer}, // Install the reducer at the 'router' slice by default.
8 enhancers: [createEnhancer(router)],
9);
Redux is now connected to React Router! Yes, that's it.
Effort has been made to keep the history action types working. redux-data-router
exports
all the actions you know and love:
1dispatch(back()); 2dispatch(forward()); 3dispatch(go(2)); 4dispatch(goBack(2)); 5dispatch(goForward()); 6dispatch(push('/', state || {})); 7dispatch(replace('/about'));
There is a new navigate
action that is more semantically in line with how the modern
router actually works:
1dispatch(navigate('/about')); 2dispatch(navigate('/about', {replace: true})); 3dispatch(navigate(2));
History actions are casted to an equivalent navigate
action. See:
actions.js
Yes. :grin: Router navigation is a side-effect of every location state change.
createEnhancer
takes an optional options object after your router
:
1{ 2 // The key used for the router slice. 3 key: 'router', 4}
For example, the introduction could have been configured differently for your unique state structure:
1const store = configureStore( 2 reducer: {FOO_BAR: reducer}, 3 enhancers: [createEnhancer(router, {key: 'FOO_BAR'})], 4);
Up to now, libraries have been handling a history
object to synchronize Redux state with React
Router. This approach is no longer practical with current (February 2024) React Router data router
semantics.
All is not lost, however! Instead of history.listen
, we have a new API: router.subscribe
.
redux-data-router
subscribes to changes through this channel to continuously synchronize the
Redux state with the router state.
Probably not. React Router's internals aren't always easy to get into, and there may even be
issues with the approach taken here. If e.g. the internal updateState
API were made
public, we might be able to become a true SSOT.
npm ci
npm run lint && npm run test
No vulnerabilities found.
No security vulnerabilities found.