mini-forage
mini-forage is a fast and simple storage library for indexeddb
with an asyncronous localStorage-esque API
Install
npm install @immutabl3/mini-forage
How to use
Async
Because miniforage uses async storage, all methods return an promise.
It's otherwise exactly the same as the
localStorage API.
import miniforage from '@immutabl3/mini-forage';
await miniforage.setItem('key', 'value');
const result = await miniforage.getItem('key');
Storing Blobs, TypedArrays, and other JS objects
You can store JSON, ArrayBuffers, Blobs and TypedArrays in miniforage. miniforage
automatically JSON.parse() and JSON.stringify() values when getting/setting
Multiple instances
You can create multiple instances of miniforage that point to different stores
import { MiniForage } from '@immutabl3/mini-forage';
const store = MiniForage({
name: "nameHere"
});
const otherStore = MiniForage({
name: "otherName"
});
store.setItem('key', 'value');
otherStore.setItem('key', 'value2');
Library Size
As of version 1.0.0 the payload added to your app is rather small. Served using gzip compression, miniforage will add less than 1.5k to your total bundle size:
- minified
- `~3.9kB`
- gzipped
- `~1.3kB`
- brotli'd
- `~1.1kB`
License
MITå