webext-storage
A more usable typed storage API for Web Extensions
- Browsers: Chrome, Firefox, and Safari
- Manifest: v2 and v3
- Permissions:
storage
or unlimitedStorage
- Context: They can be called from any context
Sponsored by PixieBrix :tada:
Install
npm install webext-storage
Or download the standalone bundle to include in your manifest.json
.
Usage
import {StorageItem} from "webext-storage";
const username = new StorageItem<string>('username')
const username = new StorageItem('username', {defaultValue: 'admin'})
await username.set('Ugo');
await username.get();
await username.remove();
await username.set({name: 'Ugo'});
username.onChange(newName => {
console.log('The user’s new name is', newName);
});
Related
License
MIT © Federico Brigante