πŸ’Ύ Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.

Overview

localForage

Build Status NPM version Dependency Status npm jsDelivr Hits minzipped size

localForage is a fast and simple storage library for JavaScript. localForage improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple, localStorage-like API.

localForage uses localStorage in browsers with no IndexedDB or WebSQL support. See the wiki for detailed compatibility info.

To use localForage, just drop a single JavaScript file into your page:

<script src="localforage/dist/localforage.js"></script>
<script>localforage.getItem('something', myCallback);</script>

Try the live example.

Download the latest localForage from GitHub, or install with npm:

npm install localforage

Support

Lost? Need help? Try the localForage API documentation. localForage APIζ–‡ζ‘£δΉŸζœ‰δΈ­ζ–‡η‰ˆγ€‚

If you're having trouble using the library, running the tests, or want to contribute to localForage, please look through the existing issues for your problem first before creating a new one. If you still need help, feel free to file an issue.

How to use localForage

Callbacks vs Promises

Because localForage uses async storage, it has an async API. It's otherwise exactly the same as the localStorage API.

localForage has a dual API that allows you to either use Node-style callbacks or Promises. If you are unsure which one is right for you, it's recommended to use Promises.

Here's an example of the Node-style callback form:

localforage.setItem('key', 'value', function (err) {
  // if err is non-null, we got an error
  localforage.getItem('key', function (err, value) {
    // if err is non-null, we got an error. otherwise, value is the value
  });
});

And the Promise form:

localforage.setItem('key', 'value').then(function () {
  return localforage.getItem('key');
}).then(function (value) {
  // we got our value
}).catch(function (err) {
  // we got an error
});

Or, use async/await:

try {
    const value = await localforage.getItem('somekey');
    // This code runs once the value has been loaded
    // from the offline store.
    console.log(value);
} catch (err) {
    // This code runs if there were any errors.
    console.log(err);
}

For more examples, please visit the API docs.

Storing Blobs, TypedArrays, and other JS objects

You can store any type in localForage; you aren't limited to strings like in localStorage. Even if localStorage is your storage backend, localForage automatically does JSON.parse() and JSON.stringify() when getting/setting values.

localForage supports storing all native JS objects that can be serialized to JSON, as well as ArrayBuffers, Blobs, and TypedArrays. Check the API docs for a full list of types supported by localForage.

All types are supported in every storage backend, though storage limits in localStorage make storing many large Blobs impossible.

Configuration

You can set database information with the config() method. Available options are driver, name, storeName, version, size, and description.

Example:

localforage.config({
    driver      : localforage.WEBSQL, // Force WebSQL; same as using setDriver()
    name        : 'myApp',
    version     : 1.0,
    size        : 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName   : 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description : 'some description'
});

Note: you must call config() before you interact with your data. This means calling config() before using getItem(), setItem(), removeItem(), clear(), key(), keys() or length().

Multiple instances

You can create multiple instances of localForage that point to different stores using createInstance. All the configuration options used by config are supported.

var store = localforage.createInstance({
  name: "nameHere"
});

var otherStore = localforage.createInstance({
  name: "otherName"
});

// Setting the key on one of these doesn't affect the other.
store.setItem("key", "value");
otherStore.setItem("key", "value2");

RequireJS

You can use localForage with RequireJS:

define(['localforage'], function(localforage) {
    // As a callback:
    localforage.setItem('mykey', 'myvalue', console.log);

    // With a Promise:
    localforage.setItem('mykey', 'myvalue').then(console.log);
});

TypeScript

If you have the allowSyntheticDefaultImports compiler option set to true in your tsconfig.json (supported in TypeScript v1.8+), you should use:

import localForage from "localforage";

Otherwise you should use one of the following:

import * as localForage from "localforage";
// or, in case that the typescript version that you are using
// doesn't support ES6 style imports for UMD modules like localForage
import localForage = require("localforage");

Framework Support

If you use a framework listed, there's a localForage storage driver for the models in your framework so you can store data offline with localForage. We have drivers for the following frameworks:

If you have a driver you'd like listed, please open an issue to have it added to this list.

Custom Drivers

You can create your own driver if you want; see the defineDriver API docs.

There is a list of custom drivers on the wiki.

Working on localForage

You'll need node/npm and bower.

To work on localForage, you should start by forking it and installing its dependencies. Replace USERNAME with your GitHub username and run the following:

# Install bower globally if you don't have it:
npm install -g bower

# Replace USERNAME with your GitHub username:
git clone [email protected]:USERNAME/localForage.git
cd localForage
npm install
bower install

Omitting the bower dependencies will cause the tests to fail!

Running Tests

You need PhantomJS installed to run local tests. Run npm test (or, directly: grunt test). Your code must also pass the linter.

localForage is designed to run in the browser, so the tests explicitly require a browser environment. Local tests are run on a headless WebKit (using PhantomJS).

When you submit a pull request, tests will be run against all browsers that localForage supports on Travis CI using Sauce Labs.

Library Size

As of version 1.7.3 the payload added to your app is rather small. Served using gzip compression, localForage will add less than 10k to your total bundle size:

minified
`~29kB`
gzipped
`~8.8kB`
brotli'd
`~7.8kB`

License

This program is free software; it is distributed under an Apache License.


Copyright (c) 2013-2016 Mozilla (Contributors).

Comments
  • Batch writes

    Batch writes

    Batch writes together automatically, without changing the API. Fixes #301.

    ~~TODO: add tests~~ TODO: ~~find a way to stub indexedDB, so that I can~~ test the doTask and _updateDatabase functions

    Sorry for adding so many private funtions on the asyncStorage object, let me know if there's a better way to do this.

    I hope this is more or less what you were expecting, there are obviously other ways to architect the code. I'll be happy to change it if you point me to examples of what it should look like.

    opened by michielbdejong 45
  • use localforage in a serviceworker

    use localforage in a serviceworker

    Hi,

    I would like to use localforage in a serviceworker. Version 1.2.4 in Chrome 43 throws a reference error on line 963 "window undefined", because there is no window in the serviceworker.

    Window was removed in #144 but reintroduced in #237.

    Should localforage or should it not be usable in a webworker / serviceworker environment?

    I'll see if I can get it to work.

    opened by remkoboschker 30
  • localForage 1.2.2 + webpack 1.5.3 doesn't want to collaborate

    localForage 1.2.2 + webpack 1.5.3 doesn't want to collaborate

    Hello. It seems that this PR don't fix problem of using localForage with webpack. I've created gist to illustrate problem https://gist.github.com/ALF-er/83325c24019de4edc851 (just place file index.html in ./src/ dir and main.js in ./src/js/ dir). If I run "npm run dev" (it just copy index.html in ./dist/ dir, compile main.js with webpack and then run webpack-dev-server for ./dist/) I get:

    WARNING in ./~/localforage/src/localforage.js
    Critical dependencies:
    332:20-336:22 the request of a dependency is an expression
     @ ./~/localforage/src/localforage.js 332:20-336:22
    
    ERROR in ./~/localforage/src/drivers/localstorage.js
    Module not found: Error: Cannot resolve module 'localforageSerializer' in C:\dev\projects\wp_lf_test\node_modules\localforage\src\drivers
     @ ./~/localforage/src/drivers/localstorage.js 70:16-59
    
    ERROR in ./~/localforage/src/drivers/websql.js
    Module not found: Error: Cannot resolve module 'localforageSerializer' in C:\dev\projects\wp_lf_test\node_modules\localforage\src\drivers
     @ ./~/localforage/src/drivers/websql.js 63:16-59
    

    If in main.js uncomment second line (and comment first ofc) then it builds w/o errors but in browser console I get localForage.getItem - undefined function...

    Maybe you can suggest something?

    opened by ALF-er 30
  • Angular module

    Angular module

    I use angularLocalStorage because it makes synching scope data to the LocalStorage a oneliner:

    storage.bind($scope,'data');
    

    Would be awesome to have this for LocalForage, too.

    question 
    opened by afknapping 28
  • Added the option to set the database name, version and table name

    Added the option to set the database name, version and table name

    In response to the issue #82, I've added a setDbInfos method for each driver allowing users to set the name and version of the database, and also the store name. There is still some risks using this method, such as changing the store name without updating the database version.

    I've also seen the pull request #99, which could offer a good way to set some database informations.

    I'm waiting for your comments before writing tests and documentation.

    opened by ahanriat 26
  • InvalidStateError in Firefox

    InvalidStateError in Firefox

    In FF v27.0.1 occurs error:

    asyncStorage: can't open database: InvalidStateError
    InvalidStateError
    

    in this code:

    var openreq = indexedDB.open(DBNAME, DBVERSION);
    

    In Chrome v32.0.1700.107 m everything works fine. Could you help me?

    opened by coderaiser 24
  • Give access to sessionStorage

    Give access to sessionStorage

    sessionStorage has some beneficial features for which there is no real IndexedDB equivalent (I happen to use it in TogetherJS). It would be nice if you could specifically get a sessionStorage-backed database.

    wontfix 
    opened by ianb 23
  • pubsub

    pubsub

    prompt in your library implemented pubsub?

    if no, whether it is planned to add? In the documentation is a description of what is possible to realize this is a links https://developer.mozilla.org/en/docs/Web/Events/storage https://developer.mozilla.org/ru/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API

    http://tutorials.jenkov.com/html5/local-storage.html

    opened by wormen 22
  • chore(localforage): promise -> lie, use ES6 modules

    chore(localforage): promise -> lie, use ES6 modules

    This is kind of a huge refactor on my part, so it's incumbent upon me to justify it.

    Goals:

    1. Reduce dist size. No huge wins here, but the min+gz size did go from 8197 to 7676, so it's at least something.
    2. Use lie in favor of promise (since it's smaller, hence the gains above)
    3. Use ES6 modules instead of SystemJS (easier to bundle, more modern)
    4. Use Browserify+Rollupify as the primary module bundler (Babel during tests). Rollup reduces bundle size by hoisting all imported dependencies into a single scope.
    5. Move common code into shared ES6 modules instead of repeating ourselves. Using Rollup means this is essentially costless; the browserify bundle basically ends up as one big index.js.

    I'll be honest; I was hoping that the gains would be much larger, since lie is so much smaller than promise. When I swap in promise for lie with my other changes, it goes from 7676 to 8892, so it's indeed larger, just not as much as I expected. (That 8892 number also indicates I added some cruft with my non-promise changes, but TBH I can't figure out where exactly those bytes came from.)

    So I suppose I can only justify this PR based on the cleaner src format (more modularity, modern build system with ES6 modules). I also migrated from building for production with Webpack to using Browserify+Rollupify instead, but that's just because of my personal preference for Browserify and the fact that I know how to easily get it to do what I want it to do. As long as it's building UMD, it shouldn't matter one way or the other.

    Tests are failing in Chrome, but this seems to be unrelated to this PR since master is failing as well.

    opened by nolanlawson 22
  • Unable to create multiple tables within a single database

    Unable to create multiple tables within a single database

    When attempting to create a second table within a single database, nothing happens; the table isn't created and the promise or callback is not fired on any call to setItem, for example.

    I'm experiencing this issue with Google Chrome (35.0.1916.153) and IndexedDB.

    An example of the issue can be viewed here: http://jsfiddle.net/kriswillis/uK3Qz/ - After loading the fiddle, "table1" is created under the "myApp" database, when changing the page variable to 2 and re-running, "table2" is not created.

    opened by kriswillis 22
  • execution on import

    execution on import

    some parts of the code run on import making delayed or conditional usage of localForage impossible.

    https://github.com/localForage/localForage/blob/master/src/localforage.js#L55-L63

    question isomorphic/universal/SSR 
    opened by plexigras 21
  • .getItem() called synchronously in README.  Bug in example?

    .getItem() called synchronously in README. Bug in example?

    In README.md, this line seems to be executing .getItem() synchronously. As getItem() requires an asynchronous or promise methods, is this a documentation bug?

    ...
    return localforage.getItem('key');
    ...
    
    opened by blukis 0
  • Database can't be downgraded?

    Database can't be downgraded?

    Hello all,

    Similar to https://github.com/localForage/localForage/issues/658, I'm trying to understand why I get this warning on instantiation of a fresh database, and what impact it might have.

    The database "ZZZ" can't be downgraded from version 8 to version 5.

    My use case shares IndexDB between a web frontend and a service worker - with localforage as the abstraction between them.

    I have not manually set the database version, but it doesn't seem like it changes the outcome when I did.

    opened by bryanlatten 0
  • Content Security Policy Error for Chrome Extension

    Content Security Policy Error for Chrome Extension

    I'm creating a chrome extension and I want to use the local forage api with it. I included a link of the API in my html code, however, I keep getting an error in my console saying that it won't load the script because it violates the content security policy directive. I tried updating my content security policy attribute in my manifest file to include the link, but it still does not change anything. I am using manifest version 3. Why is this issue still happening? How do I fix it so that I can use local forage with my chrome extension?

    I also tried using declarativeNetRequest, but it does not seem to change the issue. Am I using it wrong? Here is what I tried:

    manifest.json

    {
      "manifest_version": 3,
    
      "name": "Savior Plugin",
      "description": "This extension will save your webpage",
      "version": "1.0",
    
      "action": {
       "default_icon": "icon.png",
       "default_popup": "popup.html"
      },
    
      "background" : {
        "service_worker": "eventPage.js",
        "type": "module"
      },
      "permissions": [
       "activeTab",
       "storage",
       "contextMenus",
       "tabs",
       "declarativeContent",
       "declarativeNetRequest",
       "favicon",
       "declarativeNetRequestWithHostAccess",
       "declarativeNetRequestFeedback"
       ],
       "host_permissions": [
        "<all_urls>"
      ],
       "content_security_policy": {
        "extension_pages": "script-src 'self'; object-src 'self'"
       },
       "declarative_net_request" : {
        "rule_resources" : [{
          "id": "ruleset_1",
          "enabled": true,
          "path": "rules_1.json"
        }]
      }
    }
    

    rules_1.json

    [
    
    {
    
    "id" : 1,
    
    "priority": 1,
    
    "action" : { "type" : "allowAllRequests" },
    
    "condition": {
    
    "urlFilter": "https://cdn.rawgit.com/*",
    
    "resourceTypes" : ["sub_frame"]
    
    }
    
    }
    
    ]
    

    HTML(not entire file, just the link to local forage)

    <body>
    
    <script src="https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js"></script>
    
    </body>
    

    I keep getting the error in chrome console that says:

    popup.html:1 Refused to load the script 'https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

    popup.html:1 Refused to load the script 'https://cdn.rawgit.com/mozilla/localForage/master/dist/localforage.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

    opened by JayAlex453 0
  • Performance issue with keys() requests in Chrome

    Performance issue with keys() requests in Chrome

    Hi there.

    I just got a weird issue. Not reproducible... sorry.

    For an unknown reason, .keys() and .iterate became very slow in my app. I wrote a script that mimics what's happening : https://jsfiddle.net/fxi/hg07voey/1/ There, .keys() is fast. Same browser. Different results.

    What could make .keys() being slow in another context ?


    Here are timing from my app, to get keys from ~200 items of 250b. Β  | ms -- | -- chrome | 4440.856 chrome incognito | 43.587 firefox | 18

    Versions :

    • Browser : Chrome 107.0.5304.110 (Official Build) (arm64)
    • localforage : 1.10.0

    I tried :

    • Removing the DB
    • Removing All DB
    • Removing application cache ( clear site data )
    • Rebooting ( you know... )

    Observations :

    • I don't have any extension.
    • In the performance profile, I've seen that nothing is happening during those 4400ms, except loads of events from localforage ( 0ms blocking)...
    opened by fxi 0
  • DOMException: Failed to execute 'put' on 'IDBObjectStore': <function> could not be cloned.

    DOMException: Failed to execute 'put' on 'IDBObjectStore': could not be cloned.

    Hello πŸ‘‹πŸΌ

    I am running into the following error when using the localforage.setItem method.

    DOMException: Failed to execute 'put' on 'IDBObjectStore': function(t){if(!(!this._popup||!this._map)){ft(t);var i=t.layer||t.target;if(this._popup._source===i&&!(i insta...<omitted>...}} could not be cloned.
        at https://btcmap.org/_app/immutable/chunks/localforage-9e4e8924.js:6:11234
        at V (https://btcmap.org/_app/immutable/chunks/localforage-9e4e8924.js:6:9129)
        at https://btcmap.org/_app/immutable/chunks/localforage-9e4e8924.js:6:11115
    

    I have read other issues submitted surrounding this error (#610 and #533) and it sounds like this error appears when you try to set a data type to IndexedDB that it cannot handle like a function. In the case above it is telling me that I am trying to do that.

    Now here is where it gets a little bit strange. I have console.logged the variable that I am setting to the local cache right before I use setItem and it does not contain any functions. It is an array of objects and the objects contain lots of data but no functions. The function it is referencing above comes from a node_module that I am using in my project. How it is ending up that localForage thinks it is included in this variable that I am trying to cache locally and not visible in the console.log I have no idea.

    Now it gets even weirder.

    Even though this error happens during the setItem function the key value in the IndexedDB DOES get updated with the new value. So even though we enter the catch part of the localForage method promise localForage.setItem.then still also runs. Because I am still achieving the desired functionality of storing the new value locally this bug is not technically stopping me from doing what I want. But I still would like to figure out why this is happening and fix it if possible. I have temporarily disabled the error toast for this function because it will appear every time it runs even though the action was successful.

    Here is an example of one of the objects in the array of objects I am setting in the store:

    {
      "id": "node:9985802993",
      "osm_json": {
        "changeset": 127516569,
        "id": 9985802993,
        "lat": 53.4423766,
        "lon": -2.2775673,
        "tags": {
          "addr:city": "Manchester",
          "addr:housenumber": "585A",
          "addr:postcode": "M21 9AF",
          "addr:street": "Wilbraham Road",
          "currency:GBP": "yes",
          "currency:XBT": "yes",
          "currency:others": "no",
          "description": "Inexpensive traditional barbers, no appointment needed.",
          "name": "RJ's",
          "opening_hours": "Mo-Sa 09:00-17:00",
          "payment:lightning": "yes",
          "payment:lightning_contactless": "yes",
          "payment:onchain": "yes",
          "phone": "+44 7812 919857",
          "shop": "hairdresser",
          "survey:date": "2022-10-14"
        },
        "timestamp": "2022-10-14T10:27:01Z",
        "type": "node",
        "uid": 16971158,
        "user": "nathan_day",
        "version": 11
      },
      "created_at": "2022-09-25T08:45:08Z",
      "updated_at": "2022-10-14T10:33:31Z",
      "deleted_at": ""
    }
    

    I tried running myObject === JSON.parse(JSON.stringify(myObject)) as suggested in the other issue and it returned false. Is there something else in my Object that is causing this error and the function referenced in the error message is unrelated? Even if that is the case why is the setItem actually completing successfully when an error is being thrown?

    Please let me know if you need any more, thanks!

    EDIT: Including the code snippet from the place I am calling localForage at:

    localforage
    	.setItem('elements', newElements)
    	.then(function (value) {
    		// set updated elements to store
    		elements.set(newElements);
    
    		// display data refresh icon on map
    		mapUpdates.set(true);
    	})
    	.catch(function (err) {
    		//elementError.set(
    		//'Could not update elements locally, please try again or contact BTC Map.'
    		//);
    		console.log(err);
    	});
    
    opened by secondl1ght 0
Releases(1.10.0)
  • 1.10.0(Aug 18, 2021)

  • 1.9.0(Jul 31, 2020)

    • Fixed TypeScript definition for getItem. It now notes that getItem can return null, so this change may cause TypeScript code that didn't account for null values to fail. See #980.

    This was shipped as a minor release as it has the potential to break TypeScript checks that weren't checking for a null return value from getItem. Note that this version otherwise introduces no new features, so you can upgrade later when you're ready to fix code to check for null return values for getItem calls.

    Source code(tar.gz)
    Source code(zip)
  • 1.8.0(Jul 20, 2020)

  • 1.7.4(Jun 5, 2020)

    • Use openKeyCursor instead of openCursor for key() retrieval. Props to @MeMark2 for the fix, and thanks to @lincolnthree and @f for additional testing!
    Source code(tar.gz)
    Source code(zip)
  • 1.7.3(Oct 26, 2018)

  • 1.7.1(Mar 30, 2018)

    The fix to #805 broke things for people and needs more testing to work, so this reverts things back to pre-module field days πŸ˜„

    If your Webpack build was breaking with 1.7.0, this should fix it.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.0(Mar 30, 2018)

    This is a largely minor release but we've added support for the "module" property in package.json–see #805.

    Bumping a minor version to make sure people's builds don't break with the new property.

    If you are experiencing build errors with webpack after upgrading, try changing your mainFields webpack config: https://github.com/localForage/localForage/issues/805#issuecomment-377500059 (thanks to @brettz9 for the tip!)

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Mar 3, 2018)

    Adds dropInstance() method to localforage. This will be an optional method for custom drivers to preserve compatibility in an effort to not make this a breaking change. Custom driver that doesn't provide the dropInstance() method will reject with a respective error when this method is invoked.

    Further improves IDB driver reliability by trying to reestablish closed connections or upgraded stores.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.6(Jan 18, 2018)

  • 1.5.5(Nov 29, 2017)

  • 1.5.4(Nov 28, 2017)

  • 1.5.3(Oct 28, 2017)

    Check whether localStorage is actually usable while initializing the driver (#730 by @jesusbotella). When using Safari on Private Browsing mode and trying to set the LocalStorage driver, will now property get a "No driver available" error on from .ready().

    Thanks to everyone who made this release possible: @jesusbotella .

    – @thgreasi

    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Oct 8, 2017)

    Highlights: Try to re-establish IDB connection after an InvalidStateError (#694 by @stkao05). Really cool for long running apps. Added Generics to iterate() TS Typings (#713 by @DaSchTour). Define custom drivers syncronously when _support isn't a function (#692 by @gabrielmaldi). Use the custom driver API for internal drivers, which makes possible to override parts of their implementation.

    Thanks to everyone who made this release possible: @jesusbotella, @dmlzj, @morkro, @DaSchTour, @5aledmaged, @eppfel, @stkao05, @gabrielmaldi, @Toub, and of course @tofumatt.

    Thanks all!

    – @thgreasi

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Feb 18, 2017)

    Defaults to IndexedDB in Safari 10.1+ (#650). Pretty sweet!

    This is a breaking change, see the CHANGELOG for more info.

    Thanks to everyone who made this release possible: @nolanlawson, @michielbdejong, @dennismartensson, @ztamizzen, @stephanebachelier, @rparrapy, @iamolivinius, and of course @thgreasi.

    Thanks all!

    – @tofumatt

    Source code(tar.gz)
    Source code(zip)
  • 1.4.3(Feb 11, 2016)

  • 1.3.3(Oct 9, 2015)

  • 1.2.10(Nov 16, 2014)

    Added the iterate() functionality to allow users to iterate through all available keys. (#283)

    Thanks so much to @lu4 for the work on this release! Also to @thgreasi for his work on #329. And to @nolanlawson for his Blob fixes! Thanks to @af7 for their work on localStorage bugs.

    1.2.10: Fixes for browserify and webpack users (#439) 1.2.9: Fixes localStorage iterate issues (#407 and #428) 1.2.4: Fixes WebKit blob issues (#381) 1.2.3: Fixes a bug with require (#378) 1.2.2: Fixes a bug with webpack (#340) 1.2.1: Fixes a bug with odd-length ArrayBuffer (#285)

    Source code(tar.gz)
    Source code(zip)
    localforage.js(89.19 KB)
  • 1.1.1(Oct 19, 2014)

    Custom drivers can now be created using the defineDriver() method. (See #282 for details.)

    Thanks again to @thgreasi for this awesome release! :+1:

    1.1.1: Fixes a bug with IE IndexedDB support not being recognized (#284; thanks @Evgenus for the fix)

    Source code(tar.gz)
    Source code(zip)
    localforage.js(80.89 KB)
  • 1.0.4(Oct 1, 2014)

    Stable API for localForage featuring node-style, error-first callbacks. Also includes great work from @thgreasi: multiple instances of localForage on the same page.

    Use IndexedDB, WebSQL, or localStorage from one simple, key/value pair API using localForage.

    Thanks so much to all of our pre-1.0 contributors! Couldn't have done it without you: @thgreasi, @ocombe, @thisandagain, @lejenome, @sole, @nantunes, @magalhas, @pgherveou, @ahanriat, @Aleanar, @ahbeng, @tomByrer, @code-vicar, @davidguttman, @BlackGlory, @iamolivinius, @jviereck, @wmluke, @genkgo, @stephanebachelier, @peterbe, @andyburke, @jontewks, @albertogasparin, @willfarrell, @rubennorte, @pelish8, @adambutler, @potch, @bartek, @PatrickHeneise, @adig

    :heart: :heart: :heart:

    1.0.4: Namespaces when using the localStorage driver are now always respected. (#276; fixes #275) 1.0.3: config() accepts a new option: driver, so users can set the driver during config rather than using setDriver(). (#273; fixes #168) 1.0.2: Checks for Safari UA and disables IndexedDB on iOS 8/OS X Yosemite (as IndexedDB support on these platforms is currently broken). (#254) 1.0.1: Fixes a bug where localforage.clear() would delete all localStorage values instead of only the ones in the localforage namespace. (#246)

    Source code(tar.gz)
    Source code(zip)
    localforage.js(77.61 KB)
  • 0.9.2(Jul 3, 2014)

    This release adds vastly improved tests using mocha and includes the ability to be run on sauce labs (and in-browser) for the first time. They are way faster and much easier to work on. :+1:

    This version also includes support for the keys() method by @code-vicar and fixes many IE-specific bugs, especially in IndexedDB.

    Version 0.9.2 fixes a few ES3 keyword bugs in IE and Cordova. (#201 and #202) Version 0.9.1 fixes a bug with the ready() promise not being rejected on error.

    Source code(tar.gz)
    Source code(zip)
    localforage.js(71.94 KB)
  • 0.8.1(May 6, 2014)

  • 0.6.2(Apr 22, 2014)

    This release adds the localforage.config() method, allowing localForage's config to be set after the library has been loaded (but before the first API call).

    This release improve all errors. (#60)

    This release removes support for window.localForageConfig.

    Source code(tar.gz)
    Source code(zip)
    localforage.js(69.37 KB)
  • 0.3.1(Apr 6, 2014)

    This is a bugfix release: localForage now uses WebSQL on certain Samsung Android Devices and possibly other browsers with an out-of-date IndexedDB spec.

    Thanks to @albertogasparin for catching this bug and fixing it.

    This release also includes all the goodies from 0.3.0, chiefly: localForage doesn't load backend drivers or databases until the first API call.

    Source code(tar.gz)
    Source code(zip)
    localforage.js(64.12 KB)
  • 0.3.0(Apr 2, 2014)

    localForage now waits to load the backend storage driver until after the first public API call is made. This allows us to set the storage driver before the first getItem()/setItem()/[etc.] API call and thus never erroneously load a driver. It should also improve performance.

    Graças à @nantunes for his work on this patch.

    Source code(tar.gz)
    Source code(zip)
    localforage.js(63.74 KB)
  • 0.2.0(Mar 20, 2014)

    localForage now supports storing ArrayBuffers, Blobs, and TypedArrays in all drivers. This allows things like MP3s or images to be saved offline in any driver.

    Additionally, this includes config options found in 0.1.1, allowing users to set the name of their database.

    Source code(tar.gz)
    Source code(zip)
    localforage.js(64.00 KB)
Owner
localForage
Offline storage, improved. Wraps IndexedDB, WebSQL, or localStorage using a simple but powerful API.
localForage
Browser storage interface for IndexedDB, WebSQL, LocalStorage, and in memory data with Schema and data validator.

Client Web Storage Browser storage interface for IndexedDB, WebSQL, LocalStorage, and in memory data with basic Schema and data validation. Installati

Before Semicolon 19 Sep 30, 2022
Expirable data storage based on localStorage and sessionStorage.

Expirable storage About The Project Expirable data storage based on localStorage and sessionStorage. Getting Started To get a local copy up and runnin

Wayfair Tech – Incubator 5 Oct 31, 2022
A enhanced web storage with env support, expire time control, change callback and LRU storage clear strategy.

enhanced-web-storage A enhanced web storage with env support, expire time control, change callback and LRU storage clear strategy. How to Start import

Ziwen Mei 15 Sep 10, 2021
Simple window.localStorage, with type safety

mini-local-storage simple window.localStorage, with type safety example // localStorage.ts import { createLocalStorage } from "mini-local-storage";

Kipras Melnikovas 4 Jan 8, 2023
db.js is a wrapper for IndexedDB to make it easier to work against

db.js db.js is a wrapper for IndexedDB to make it easier to work against, making it look more like a queryable API. Usage Add a reference to db.js in

Aaron Powell 790 Nov 28, 2022
A script and resource loader for caching & loading files with localStorage

Basket.js is a script and resource loader for caching and loading scripts using localStorage ##Introduction for the Non-Developer Modern web applicati

Addy Osmani 3.4k Dec 30, 2022
localStorage and sessionStorage done right for AngularJS.

ngStorage An AngularJS module that makes Web Storage working in the Angular Way. Contains two services: $localStorage and $sessionStorage. Differences

G. Kay Lee 2.3k Nov 26, 2022
Vue.js localStorage plugin with types support

VueLocalStorage LocalStorage plugin inspired by Vue typed props which take a care of typecasting for Vue.js 1 and 2 with SSR support. Install npm inst

Alexander Avakov 669 Nov 29, 2022
:lock: Secure localStorage data with high level of encryption and data compression

secure-ls Secure localStorage data with high level of encryption and data compression. LIVE DEMO Features Secure data with various types of encryption

Varun Malhotra 602 Nov 30, 2022
⁂ The simple file storage service for IPFS & Filecoin

⁂ web3.storage The simple file storage service for IPFS & Filecoin. Getting started This project uses node v16 and npm v7. It's a monorepo that use np

Web3 Storage 423 Dec 25, 2022
This is an upload script which allows you to upload to web3 storage using JS.

This is an upload script which allows you to upload to web3 storage using JS. first make sure to run npm install on the directory run script using nod

null 1 Dec 24, 2021
Cross-browser storage for all use cases, used across the web.

Store.js Cross-browser storage for all use cases, used across the web. Store.js has been around since 2010 (first commit, v1 release). It is used in p

Marcus Westin 13.9k Dec 29, 2022
Cross domain local storage, with permissions

Cross domain local storage, with permissions. Enables multiple browser windows/tabs, across a variety of domains, to share a single localStorage. Feat

Zendesk 2.2k Jan 6, 2023
JS / CSS / files loader + key/value storage

bag.js - JS / CSS loader + KV storage bag.js is loader for .js / .css and other files, that uses IndexedDB/ WebSQL / localStorage for caching. Conside

Nodeca 86 Nov 28, 2022
A lightweight vanilla ES6 cookies and local storage JavaScript library

?? CrumbsJS ?? A lightweight, intuitive, vanilla ES6 fueled JS cookie and local storage library. Quick Start Adding a single cookie or a local storage

null 233 Dec 13, 2022
:sunglasses: Everything you need to know about Client-side Storage.

awesome-web-storage Everything you need to know about Client-side Storage. Table of Contents Introduction Browser Support Cookies Pros Cons API Useful

Varun Malhotra 420 Dec 12, 2022
An AngularJS module that gives you access to the browsers local storage with cookie fallback

angular-local-storage An Angular module that gives you access to the browsers local storage Table of contents: Get Started Video Tutorial Development

Gregory Pike 2.9k Dec 25, 2022
local storage wrapper for both react-native and browser. Support size controlling, auto expiring, remote data auto syncing and getting batch data in one query.

react-native-storage This is a local storage wrapper for both react native apps (using AsyncStorage) and web apps (using localStorage). ES6 syntax, pr

Sunny Luo 2.9k Dec 16, 2022
A javascript based module to access and perform operations on Linode object storage via code.

Linode Object Storage JS Module A javascript based module to access and perform operations on Linode object storage via code. Code Guardian Installing

Core.ai 3 Jan 11, 2022