Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

๐Ÿ›ข Nuxt-Storage

All Contributors version downloads Travis codecov Dependencies

Utilities for easy read and write browser's storage in Nuxt.js project

Why I need this package?

In Nuxt, it's hard to play with browser's storage like sessionStorage and localStorage. This package will help you handle client side storage with a simple API and with various useful additional features such as expiry.

How to install and use

Install using NPM or Yarn

# NPM
$ npm i nuxt-storage

# Yarn
$ yarn add nuxt-storage

Sample using this package

Set data
import nuxtStorage from 'nuxt-storage';

nuxtStorage.localStorage.setData('key', 'value');
nuxtStorage.sessionStorage.setData('key', 'value');

//Set data with expiry time

// default time is 5 minutes, set it to 15
nuxtStorage.localStorage.setData('key', 'value', 15);

// default time unit is minutes , set it to hours, so type 'h'
nuxtStorage.localStorage.setData('key', 'value', 1, 'h');
Get data by value
nuxtStorage.localStorage.getData('key');
nuxtStorage.sessionStorage.getData('key');
Remove or clear storage (localStorage/sessionStorage)
// Remove single item by **key**
nuxtStorage.localStorage.removeItem('key');
nuxtStorage.sessionStorage.removeItem('key');

// Clear entire storage
nuxtStorage.localStorage.clear());
nuxtStorage.sessionStorage.clear();

API options

Method Name Parameter Default Value Available Options
getData key (type: String) Empty String
setData key (type: String) Empty String
value (type: any) Empty String
expiry (type: Number) 5
expiryUnit (type: String) m s = second, m = minutes, h = hour, d = day
removeItem key (type: String)
clear -

Support me


Copyright ยฉ 2018 by Irfan Maulana

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

notjiam
notjiam

โš ๏ธ ๐Ÿ›
Irfan Maulana
Irfan Maulana

๐Ÿ› ๐Ÿšง โš ๏ธ ๐Ÿ’ป
Jakub Zomerfeld
Jakub Zomerfeld

๐Ÿ“

This project follows the all-contributors specification. Contributions of any kind welcome!