# has-localstorage

> returns true if localStorage is supported _and_ persistent

Latest version **1.0.1** (published 2015-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install has-localstorage
pnpm add has-localstorage
yarn add has-localstorage
bun add has-localstorage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-01-03 |
| First published | 2015-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Gregor Martynus |
| Maintainers | gr2m |
| Keywords | localstorage, browser, data |

## Links

- npm: https://www.npmjs.com/package/has-localstorage
- Repository: https://github.com/gr2m/has-localstorage
- Homepage: http://gr2m.github.com/has-localstorage
- Issues: https://github.com/gr2m/has-localstorage/issues
- npm.io page: https://npm.io/package/has-localstorage

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-01-03
- 1.0.0 — 2015-01-02

## README

# has-localstorage

> returns true if localStorage is supported _and_ persistent

[![Build Status](https://travis-ci.org/gr2m/has-localstorage.png?branch=master)](https://travis-ci.org/gr2m/has-localstorage/)

returns `true` or `false` depending on whether localStorage is supported or not.
Beware that some browsers like Safari do not support localStorage in private mode.


## Downlaod or Installation

- Download [has-localstorage.js](https://raw.githubusercontent.com/gr2m/has-localstorage/master/lib/has-localstorage.js)
- or: install via Bower: `bower install --save has-localstorage`
- or: install via npm: `npm install --save has-localstorage`


## Usage

```js
if (hasLocalStorage()) {
  // localStorage can be used, all data gets persisted
} else {
  // localStorage is not available, or changes are not persisted
}
```


## Help wanted!

The current test setup is very simple: it only tests in latest Firefox
using Selenium and [Sauce Labs](http://saucelabs.com/). Unfortunately,
Sauce Labs has no support to start browsers in private mode, which would
be necessary, as `localStorage` behaves different if in private mode
in Safari, probably in other browsers as well.

If anynone has an idea to for that, ping me at
https://github.com/gr2m/has-localstorage/issues/1


# Acknowledgement

`hasLocalStorage()` has been inspired by this [Cappuccino](http://www.cappuccino-project.org/) commit:
https://github.com/cappuccino/cappuccino/commit/063b05d9643c35b303568a28809e4eb3224f71ec

## License

MIT

---
_Source: https://npm.io/package/has-localstorage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
