https://github.com/derektmueller/redux-query-string-state
Redux middleware to synchronize Redux state with URL query string
https://github.com/derektmueller/redux-query-string-state
Last synced: 5 months ago
JSON representation
Redux middleware to synchronize Redux state with URL query string
- Host: GitHub
- URL: https://github.com/derektmueller/redux-query-string-state
- Owner: derektmueller
- License: mit
- Created: 2017-11-14T06:50:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-14T07:05:19.000Z (over 8 years ago)
- Last Synced: 2025-09-06T02:32:38.038Z (9 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Redux middleware for synchronizing the URL query string with Redux state. Redux state keys can be mapped to query string parameters. When the Redux state updates, the state is JSON and url encoded and added to the URL query string. On page load, the Redux state is hydrated from the state encoded in the URL query string.
## Usage
```
import { combineReducers, createStore, applyMiddleware } from 'redux'
import reducers from 'reducers';
import UrlState from 'middleware/urlState';
const urlState = new UrlState(['exampleReducer1']);
const reducers = combineReducers({
exampleReducer1: () => {},
exampleReducer2: () => {}
});
const store = createStore(
reducers,
urlState.getPreloadedState(),
applyMiddleware(urlState.getMiddleware()));
```
## Development
```
npm install
```
## Testing
```
npm run-script test
```