Curated set of modifiers for storage-engine

Usage no npm install needed!

<script type="module">
  import storageModifiers from '';



This is curated set of modifiers that can be used with the storage-engine library.


This package is released in the public npm registery and should be used inconjuction with the storage-engine library:

npm install --save storage-modifiers
npm install --save storage-engine


The following modifiers are available in this package:

  • json Automatically JSON encode / decode payloads.
  • emit Emit events when keys are modified.
  • expire Expire data.
  • encrypt Encrypt the contents of your AsyncStorage


Adds automatic JSON encoding and decoding. The mergeItem and multiMerge API's of the AsyncStorage API already promote the usage of JSON for your values. This plugin does it automatically for you.

import { json } from 'storage-modifiers';
import storage from 'storage-engine';

storage.use('*', json);

await storage.setItem('this', {
  would: 'not',
  work: {
    without: 'the'
  plugin: true

const value = await storage.getItem('this') // { would: "not", ...}


Allows you to emit an event every time when a given key is accessed, this allows you for example to track changes to values.

import { expire } from 'storage-modifiers';
import storage from 'storage-engine';

storage.use('*', expire, {
  key: true,
  operation: true

storage.on('key', function ({ method, key, value }) {
  console.log(`${method} accessed "key" which now has value:`, value);

storage.on('setItem', function ({ method, key, value }) {
  console.log('what is up from `setItem` is a called on key:', key);

await storage.setItem('key', 'value');

// console output:
// - setItem accessed "key" which is now has value: "value"
// - what is up from `setItem` is called on key: "key"

The emit plugin understands the following options:

  • key Emit the events with the key as event name.
  • operation Emit the operation as event name.


Allows you to automatically expire keys and remove it from your AsyncStorage.

import { expire } from 'storage-modifiers';
import storage from 'storage-engine';

storage.use('key, another, foo*', expire, {
  duration: '10 minutes'

await storage.setItem('key', 'data'); // expires in 10 minutes

The expire plugin understands the following options:

  • duration The TTL of the values that get stored in these keys.


Provides an additional layer of security for AsyncStorage by encrypting the values using crypto-js. This ensures that when the AsyncStorage is flushed to disk, the contents will still be encoded.

import { encrypt } from 'storage-modifiers';
import storage from 'storage-engine';

storage.use('secure*', encrypt, {
  secret: 'your secret here',
  encryption: 'SHA3'

The encrypt plugin understands the following options:

  • secret, required, The secret key/passcode to use to encode/decode contents.
  • encryption, required, The encryption algorithm to use. Can be any of the supported encryption libraries; Please note that casing is important here sha3 is invalid, while SHA3 is accepted.