Use chrome.storage with promises
npm install chrome-storage-promisesThis tiny module provides Promise based functions for extensions using chrome.storage
``sh`
yarn add chrome-storage-promises
or
`sh`
npm i chrome-storage-promises
You will also need the storage permission in your manifest file:
`json`
{
"name": "My extension",
...
"permissions": [
"storage"
],
...
}
Before using this module, check out the official documentation of chrome.storage.
First import the desired storage method:
`ts`
import { local } from "chrome-storage-promises";
Than, you can use it, like normal async/await promises:
`ts
await local.set({ test: "an-example-value" });
const testValue = await local.get("an-example-value");
``