All Projects → feat7 → client-persist

feat7 / client-persist

Licence: other
Offline storage for your web client. Supports IndexedDB, WebSQL, localStorage and sessionStorage with an easy to crawl with API.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
typescript
32286 projects

Projects that are alternatives of or similar to client-persist

Localforage
💾 Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
Stars: ✭ 19,840 (+141614.29%)
Mutual labels:  localstorage, indexeddb, websql, localforage
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (+114.29%)
Mutual labels:  localstorage, indexeddb, websql
persistence
💾 Persistence provides a pretty easy API to handle Storage's implementations.
Stars: ✭ 18 (+28.57%)
Mutual labels:  localstorage, indexeddb, sessionstorage
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+435.71%)
Mutual labels:  localstorage, sessionstorage, localforage
svelte-persistent-store
A Svelte store that keep its value through pages and reloads
Stars: ✭ 111 (+692.86%)
Mutual labels:  localstorage, indexeddb, sessionstorage
localForage-cn
localForage中文仓库,localForage改进了离线存储,提供简洁健壮的API,包括 IndexedDB, WebSQL, 和 localStorage。
Stars: ✭ 201 (+1335.71%)
Mutual labels:  localstorage, indexeddb, localforage
Immortaldb
🔩 A relentless key-value store for the browser.
Stars: ✭ 2,962 (+21057.14%)
Mutual labels:  localstorage, indexeddb, sessionstorage
browserStorage
浏览器本地存储封装
Stars: ✭ 30 (+114.29%)
Mutual labels:  localstorage, sessionstorage, websql
Remotestorage.js
⬡ JavaScript client library for integrating remoteStorage in apps
Stars: ✭ 2,155 (+15292.86%)
Mutual labels:  localstorage, indexeddb
Brownies
🍫 Tastier cookies, local, session, and db storage in a tiny package. Includes subscribe() events for changes.
Stars: ✭ 2,386 (+16942.86%)
Mutual labels:  localstorage, sessionstorage
ng2-storage
A local and session storage wrapper for angular 2.
Stars: ✭ 14 (+0%)
Mutual labels:  localstorage, sessionstorage
React Local Storage
Showcase on how to use the native localStorage of the browser in React.
Stars: ✭ 168 (+1100%)
Mutual labels:  localstorage, sessionstorage
Ngx Store
Angular decorators to automagically keep variables in HTML5 LocalStorage, SessionStorage, cookies; injectable services for managing and listening to data changes and a bit more.
Stars: ✭ 152 (+985.71%)
Mutual labels:  localstorage, sessionstorage
stoor
Storage wrapper with support for namespacing, timeouts and multi get/set and remove.
Stars: ✭ 26 (+85.71%)
Mutual labels:  localstorage, sessionstorage
React Storage Hooks
React hooks for persistent state
Stars: ✭ 146 (+942.86%)
Mutual labels:  localstorage, sessionstorage
Jest Localstorage Mock
A module to mock window.localStorage and window.sessionStorage in Jest
Stars: ✭ 247 (+1664.29%)
Mutual labels:  localstorage, sessionstorage
Redux React Session
🔑 Simple Session API storage for Redux and React
Stars: ✭ 140 (+900%)
Mutual labels:  localstorage, indexeddb
Awesome Web Storage
😎 Everything you need to know about Client-side Storage.
Stars: ✭ 227 (+1521.43%)
Mutual labels:  localstorage, sessionstorage
elm-storage
Unified interface for accessing and modifying LocalStorage, SessionStorage and Cookies
Stars: ✭ 13 (-7.14%)
Mutual labels:  localstorage, sessionstorage
vue-storage-watcher
a reactive storage plugin for vue 👀🔭
Stars: ✭ 60 (+328.57%)
Mutual labels:  localstorage, sessionstorage

client-persist

This is fork of localForage with support of sessionStorage

Offline storage for your web client. Supports IndexedDB, WebSQL, localStorage and sessionStorage with an easy to crawl with API.

Installation

yarn add client-persist

or, if you use npm

npm install client-persist

Usage

import clientPersist from 'client-persist';

// to use sessionStorage
clientPersist.setDriver(clientPersist.SESSIONSTORAGE)

A minimal example with React

import React from "react";
import clientPersist from "client-persist";

clientPersist.setDriver(clientPersist.SESSIONSTORAGE);

class App extends React.Component {
  constructor() {
    super();
    this.state = {
      value: "Client Persist"
    };
    clientPersist.getItem("value").then(value => {
      if (value !== null) this.setState({ value });
    });
  }
  storeValue(event) {
    clientPersist.setItem("value", event.target.value)
    .then(() => console.log('--saved--'));
    this.setState({
      value: event.target.value
    });
  }
  render() {
    return (
      <div>
        <h1>Hello {this.state.value}!<h1>
        <h2>Edit and reload the browser!</h2>
        <input
          type="text"
          onChange={event => this.storeValue(event)}
          value={this.state.value}
        />
      </div>
    );
  }
}

Edit k983rnkl3v

Documentation

Documentation of localForage

client-persist provides additonal driver for sessionStorage on localForage.

sessionStorage driver can be selected by setDrvier method.

clientPersist.SESSIONSTORAGE is driver for sessionStorage compatibility.

Store and Retrive data

import clientPersist from 'client-persist';

//Set sessionStorage driver
clientPersist.setDriver(clientPersist.SESSIONSTORAGE);

// Driver options
// clientPersist.LOCALSTORAGE, clientPersist.WEBSQL,
// clientPersist.INDEXEDDB, clientPersist.SESSIONSTORAGE

clientPersist.setItem('keyName', 'This is some data')
.then(() => console.log('Data saved');

clientPersist.getItem('keyName')
.then(value => console.log(value));

License

See LICENSE file.

More

See localForage for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].