1.0.0 • Published 5 years ago

@codewell/state-persistor v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@codewell/state-persistor

Minimalistic state persistor for front end applications with localstorage.

Installation

npm install @codewell/state-persistor

Basic usage

import { saveState, loadState, purgeState } from '@codewell/state-persistor';

const state = {}; // Some state
const STORAGE_KEY = 'myCoolUniqueApplicationStorageKey'; // Unique key to store the state in localstorage

// Persist the state
saveState(state, STORAGE_KEY);

// Get the persisted state
const loadedState = loadState(STORAGE_KEY);

// Clear any saved state
purgeState(STORAGE_KEY);