npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-persist-x

v1.1.5

Published

**redux-persist-x** is a lightweight and efficient persistence library for Redux, designed to keep your Redux store state in sync across multiple storage options. With a tiny bundle size of just **4KB**, `redux-persist-x` makes it easy to persist and rehy

Downloads

473

Readme

redux-persist-x

redux-persist-x is a lightweight and efficient persistence library for Redux, designed to keep your Redux store state in sync across multiple storage options. With a tiny bundle size of just 4KB, redux-persist-x makes it easy to persist and rehydrate your store while keeping your builds lean.

Features

  • Tiny bundle size – only 4KB!

  • Flexible storage support – integrates with IndexedDB, localStorage, and sessionStorage

  • Optimized builds with tree-shaking and minification

  • Simple API for easy persistence and rehydration of your Redux store

  • Flexible Storage Options: Supports integration with other storage modules like localStorage, sessionStorage, or custom storage solutions

  • Easy-to-Use API: Designed to mimic the functionality of redux-persist for a smooth migration experience

Installation

Install redux-persist-x via npm or yarn:

npm install redux-persist-x
# or
yarn add redux-persist-x

Usage Examples:

  1. Basic Usage
  2. [Nested Persists][coming soon]

Basic Usage

Basic usage involves adding persistReducer and persistStore to your setup.

// configureStore.js

import { configureStore, createReducer } from '@reduxjs/toolkit';
import { combineReducers } from 'redux';
import { persistReducer } from 'redux-persist-x'; // defaults to localStorage for web

import rootReducer from './reducers'

const persistConfig = {
  whiteList: ["fileReducer"],
  storageType: "localStorage" //it can be localStorage,sessionStorage and indexedDB 
  //storage:, storage can be any storages(It is optional)
  expireDate:1730298664   //end of persisiting data 
}

const persistedReducer = persistReducer(rootReducer,persistConfig)

export const store = configureStore({
  reducer: persistedReducer,
});

If you are using react, wrap your root component with PersistWrapper.

import { PersistWrapper } from "redux-persist-x";


const App = () => {
  return (
    <Provider store={store}>
      <PersistWrapper  store={store}>
        <RootComponent />
      </PersistWrapper>
    </Provider>
  );
};

API

persistReducer(reducer,config)

  • arguments
    • [config] object
      • required config: storageType
      • notable other config: whitelist, expireDate, optional storage
    • reducer function
      • any reducer will work, typically this would be the top level reducer returned by combineReducers

persistor methods

  • the persistor object is returned by persistStore with the following methods:
    • purgePersistReducer()
      • purges state from disk and returns a promise
    • pausePersistReducer()
      • pauses persistence

Storage Engines

Community & Contributing

We welcome contributions from everyone! Whether you’re fixing bugs, suggesting new features, or improving documentation, your help is greatly appreciated. If you'd like to get involved, please feel free to open issues, create pull requests, or simply reach out to discuss ideas.

For any questions or to start a conversation, you can email me directly at [[email protected]]. Let’s build something great together!