Gathering detailed insights and metrics for redux-history-sync
Gathering detailed insights and metrics for redux-history-sync
Gathering detailed insights and metrics for redux-history-sync
Gathering detailed insights and metrics for redux-history-sync
npm install redux-history-sync
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
169 Commits
1 Forks
1 Watchers
241 Branches
3 Contributors
Updated on Mar 21, 2021
Latest Version
3.2.2
Package Id
redux-history-sync@3.2.2
Size
37.02 kB
NPM Version
5.3.0
Node Version
8.1.4
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
Essentially, this module syncs browser history locations with a Redux store. If you are looking to read and write changes to the address bar via Redux this might be for you.
This module is intended to be the only module in your app that manages or touches window.history. If you want integration with react-router
or history
look elsewhere.
npm install --save redux-history-sync
This library saves each browser history entry to Redux. You can easily read every location a user has visited within the app from Redux. The app is therefor able to render a list of all the "pages" a user has visited from the Redux store. Clicking on one of those pages to navigate to that historical page is the same as selecting it from the browsers history. Doing so will emit the RESTORE_HISTORY
action type.
If the app developer clicks "Reset" in Redux DevTools the browser history pointer is updated to the location when the app was loaded. If you disable the most current action that resulted in a page change it will move the browser history position back 1. If you navigate around to 6 pages and click "Reset" it is the same as clicking the back button 6 times. Clicking "Reset" and then clicking the browsers back button should exit the app to whatever page the browser visited previously. If browser window loaded the app first the back button will be disabled.
Navigating to a new "page" should act like it. UI state should reset/restore as you navigate to a new page or click back/forward. Filters enabled on one page should probably not carry over to another page. Clicking the browsers back/forward buttons while in the app is actually RESTORE_HISTORY
not CREATE_HISTORY
. If the app is going to change the url shown in the address bar it should probably be a new history entry both in the browsers history (via history.pushState) and in Redux. Therefore redux-history-sync provides no action for replaceState()
. Please open an issue if you need it.
historySession
reducer. Restore previous state on navigation changes.push
event.window
object from within the library. This might change in the future.1import { 2 getInitState, historyMiddleware, historyReducer, syncHistoryWithStore, 3} from 'redux-history-sync' 4import { composeWithDevTools } from 'redux-devtools-extension' 5 6/* global window */ 7 8const initState = { 9 history: getInitState(window.location, window.document.title, window.history), 10} 11const reducer = { 12 history, 13} 14const store = createStore( 15 reducer, 16 initState, 17 composeWithDevTools( // Can use typical redux compose function instead. 18 applyMiddleware( 19 historyMiddleware(window.history), 20 thunk, 21 ), 22 ) 23) 24syncHistoryWithStore(store, window)
1import { createHistory } from 'redux-history-sync' 2 3dispatch(createHistory('/some/new/location')) 4
createHistory(location, title, key = null, pushState = true)
HISTORY_CREATE
This action should be dispatched when you want a new history entry or wish to change the location in the address bar. Usually the result of an interaction with a UI. Browser refresh and then forward can also create actions with this type.restoreHistory(key, pushState = true)
HISTORY_RESTORE
This action should be dispatched when you want to exchange state with a previous history. Usually triggered by the browser back/forward buttons but can also be used inside the app to change browser history position.createFromBrowser()
HISTORY_LEARN
If the user refreshes on a page the app thinks they do not have browser history. Clicking the browser back button will result in this action being triggered.getInitState(window.location, window.document.title)
Dispatch initial action on reducer for sane DevTools resets.historyMiddleware(window.history, historyCache)
historyReducer
Use this after the store is created to enable redux to control browser history.
syncHistoryWithStore(store, window, historyCache)
The address bar is a form input. It does not represent overall state. At its best the url can be parsed into an object and be used to populate a tiny portion of application state. See location-info
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
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
62 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