Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆

Subscribe to our mailing list


:left_luggage: A simplified localStorage API that just works

Subscribe to updates I use local-storage

Statistics on local-storage

Number of watchers on Github 391
Number of open issues 8
Average time to close an issue 2 days
Main language JavaScript
Average time to merge a PR 4 days
Open pull requests 5+
Closed pull requests 4+
Last commit about 4 years ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 229 KB
Organization / Authorbevacqua
Page Updated
Do you use local-storage? Leave a review!
View open issues (8)
View local-storage activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating local-storage for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


A simplified localStorage API that just works


Using npm

npm install local-storage --save

Using bower

bower install localstorage --save


The API is a simplified way to interact with all things localStorage. Note that when localStorage is unsupported in the current browser, a fallback to an in-memory store is used transparently.

For that reason, consider that local-storage values might evaporate across page views.

ls(key, value?)

If a value argument is provided, acts as ls.set. When value isn't provided, acts as ls.get.

var ls = require('local-storage');

// <- null

ls('foo', 'bar');
// <- true

// <- 'bar'


Returns value under key in local storage. Equivalent to ls(key). Internally parses the value from JSON before returning it.

var ls = require('local-storage');

ls('foo', 'bar');
// <- true

// <- 'bar'

ls.set(key, value)

Persists value under key in local storage. Equivalent to ls(key, value). Internally converts the value to JSON.

Returns whether an error was thrown by the browser when trying to persist the value. Failure typically means a QuotaExceededError was thrown.

var ls = require('local-storage');

ls.set('foo', 'bar');
// <- true

// <- 'bar'


Removes key from local storage. Returns true if the property was successfully deleted, and false otherwise.

var ls = require('local-storage');

ls.set('foo', 'bar');
// <- true

// <- true


Clears local storage.

var ls = require('local-storage');

ls.set('foo', 'bar');
ls.set('baz', 'tar');

ls.on(key, fn)

Listen for changes persisted against key on other tabs. Triggers fn when a change occurs, passing the following arguments.

  • value: the current value for key in local storage, parsed from the persisted JSON
  • old: the old value for key in local storage, parsed from the persisted JSON
  • url: the url for the tab where the modification came from

Open a page with the following snippet in multiple tabs. The storage event will trigger on all tabs except for the one that persisted the change.

var ls = require('local-storage');

ls.on('foo', storage);
ls.set('foo', 'bar');

function storage (value) {
  console.log('some other tab changed "foo" to ' + value);
}, fn)

Removes a listener previously attached with ls.on(key, fn).

var ls = require('local-storage');

ls.on('foo', storage);'foo', storage);

function storage (value) {
  console.log('some other tab changed "foo" to ' + value);



local-storage open issues Ask a question     (View All Issues)
  • about 3 years Does this work with subdomains?
  • about 4 years Does this support IE8?
local-storage open pull requests (View All Pulls)
  • Allow the local storage backend to be replaced.
  • protect against Chrome throwing errors on localStorage access attempts
  • Typescript support
  • Get all localstorage properties
  • Clarify ls.set() return value description.
local-storage questions on Stackoverflow (View All Questions)
  • Destruction of static class members in Thread local storage
  • HTML5 local storage broken in ie11 win 8.1 x64 ? error: function expected
  • Can gcc's thread-local storage share cache lines across threads?
  • gameover page - Can't save to local storage
  • Unable to retrieve local storage variable
  • Why does Local Storage increase size of value?
  • Angular Restangular Local Storage Interceptor Issue
  • angular update local storage single object
  • Using Mobile local storage as database in MeteorJS
  • I want to save data in local storage first and later sync it to cloud database by Parse
  • Angular Satellizer removing JWT from local storage when expired?
  • Cocoa: WKWebView local storage
  • Local storage to store unordered list items having images as children
  • Saving form data to local storage giving undefined
  • how to backup html 5 local storage data
  • Android: loading bitmap from local storage into app widget (RemoteViews)
  • Print Local Storage onto page
  • save table sort in local storage
  • How do I quicksort something based on its variable in local storage?
  • jQuery cannot pass local storage to PostgreSQL via php on AWS with Phonegap app
  • Store Var Into Local Storage
  • Local Storage, Session storage, Web storage, web database and cookies in HTML5
  • Angular Factory Object Persisting Over Storing in Local Storage
  • Can I approximate browser cache rates with local storage?
  • Jasmine and angular mocks : mocking a service that handles local storage
  • Save accessToken to local storage using passport-facebook
  • Store visit datas in local storage when no net,after network on,refresh must insert datas into web service
  • jQuery - Local Storage sort stringified object order
  • On first time visit- popup a div asking user name, then store it and the date on local storage
  • read a file from iPhone local storage
local-storage list of languages used
Other projects in JavaScript