Detect if web storage is available and functional
This microscopically small module contains only a single function,
storageAvailable, that detects whether the Web Storage API methods are available. The reason you would want to use a separate module for feature detecting Web Storage is because it is hard and error prone.
npm install --save storage-available
var storageAvailable =
if// Yippee! We can use localStorage awesomenesselse// Too bad, no localStorage for us
You can test for sessionStorage instead by calling
NOTE: This module is intended for use in the browser, or other environments that natively support Web Storage. Use it via a web bundler such as Browserify or Webpack.
Credits to Paul Irish for hist gist summarizing the development of feature detecting localStorage, and to all people who contributed fixes to it in that process.
Add an issue in this project's issue tracker to let me know of any problems you find, or questions you may have.
Licensed under the MIT Open Source license.