redux-persist-sqlite
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

redux-persist-sqlite-storage

A redux-persist storage adapter that writes to sqlite.

This is adapted from https://github.com/prsn/redux-persist-sqlite-storage, but uses Node.js sqlite3 rather than react-native.

Great for Electron apps that are backed by Redux.

install

npm i redux-persist-sqlite-storage

usage

// configureStore.ts
import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import { SQLiteAdapter }  from 'redux-persist-sqlite-storage'
 
const yourDbName = 'redux-persist.db';
const pathToYourDB = path.join(process.cwd(), yourDbName);
 
const rootPersistConfig = {
  key: 'root',
  storage: new SQLiteAdapter(pathToYourDB)
};
 
const persistedReducer = persistReducer(persistConfig, rootReducer);
 
export function configureStore() {
  const store = createStore(persistedReducer);
  const persistor = persistStore(store);
  return { store, persistor };
}

/redux-persist-sqlite/

    Package Sidebar

    Install

    npm i redux-persist-sqlite

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    12.1 kB

    Total Files

    4

    Last publish

    Collaborators

    • charliehess