You can use IndexedDB in WebWorkers , which allows you to store things locally in the keystore. This is not the same as localStorage, but it has similar use cases and can contain quite a lot of data. We use IndexedDB at WebWorkers at my work.
August 2019 EDIT:
There is a suggested API that may appear in the future (although it is currently available in Chrome Canary with the experimental web functions flag enabled). It is called KV Storage (KV stands for Key Value). It has an almost identical interface with the localStorage API and comes with JavaScript modules. It is built on top of the indexeddb API, but has a much simpler API. Looking at Spec , it seems that this will work in WebWorkers. For examples of how to use it, see the github specification page. Here is one such example:
import storage, { StorageArea } from "std:kv-storage"; import {test, assert} from "./florence-test"; test("kv-storage test",async () => { await storage.clear() await storage.set("mycat", "Tom"); assert(await storage.get("mycat") === "Tom", "storage: mycat is Tom"); const otherStorage = new StorageArea("unique string"); await otherStorage.clear() assert(await otherStorage.get("mycat") === undefined, "otherStorage: mycat is undefined"); await otherStorage.set("mycat", "Jerry"); assert(await otherStorage.get("mycat") === "Jerry", "otherStorage: mycat is Jerry"); });
Here are the tests passing in Chrome Canary:

Although it is not necessary to use the kv repository API, the code below is a test environment used for the above code:
John Dec 18 '15 at 19:38 2015-12-18 19:38
source share