Redux Cookies Middleware is a specialized Redux middleware designed to synchronize specific parts of a Redux state tree with browser cookies. Developers configure `paths` to indicate which state subsets, using dot-notation, should be persisted, along with their corresponding cookie names. It also offers `getStateFromCookies` to hydrate the initial Redux state from existing cookies, ensuring state continuity across sessions. The current stable version is 0.2.1. However, the project appears to be abandoned, with its last commit occurring in November 2018 and no significant updates since, which means it likely does not support modern Redux Toolkit patterns or ESM-only environments directly. Its primary differentiation lies in its explicit, configurable mapping of state paths to individual cookies, offering fine-grained control over what data is stored on the client side.
npm install redux-cookies-middlewareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `redux-cookies-middleware` to persist specific parts of the Redux state ('auth.token' and 'session') into browser cookies, and how to hydrate the initial state from those cookies upon application load.
Evaluate alternatives like `redux-persist` or implement custom cookie logic for state persistence in modern applications.
Thoroughly test state hydration logic when upgrading from versions prior to 0.2.0 to ensure expected behavior, especially with complex initial state structures or diverse cookie values.
Use constants for path strings where possible, and ensure robust testing of cookie persistence logic whenever your Redux state shape evolves.
Ensure custom `equalityCheck` and `deleteCheck` functions are pure, performant, and thoroughly tested, especially when dealing with complex data structures. Leverage a reliable deep equality checker if necessary (e.g., `lodash.isequal`).
Upgrade to `redux-cookies-middleware` v0.2.0 or higher to utilize the fixed, non-mutating `getStateFromCookies` implementation.
Upgrade to `redux-cookies-middleware` v0.2.0 or higher, which includes improved error handling and robustness when attempting to parse potentially malformed JSON cookie values.
No dependency data recorded yet.