StorageArea.getKeys()

Retrieves the keys of all items in a storage area.

Syntax

js
let results = browser.storage.<storageType>.getKeys();

Where <storageType> is one of the storage types: sync, local, session, or managed.

Parameters

This method takes no parameters.

Return value

A Promise that resolves to an array containing storage item keys.

If the operation fails, the promise is rejected with an error message.

If managed storage is not set, undefined is returned.

Warning: In Firefox, if an extension's managed storage has not been configured with a native manifest or using the 3rdparty enterprise policy, an exception is thrown when using this function to access managed storage (see Firefox bug 1868153). This issue can be avoided by catching the error. This issue is related to the lack of support for the storage.managed_schema manifest key (see Firefox bug 1771731).

Examples

Suppose storage contains two items:

js
// storage contains two items, "kitten" and "monster"
browser.storage.local.set({
  kitten: { name: "Mog", eats: "mice" },
  monster: { name: "Kraken", eats: "people" },
});

Retrieve keys of all items in storage.local and log the result.

js
browser.storage.local
  .getKeys()
  .then((keys) => console.log(keys)) // [ "kitten", "monster" ]
  .catch((err) => console.error(`Error: ${err}`));

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getKeys
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Full support
Firefox 143 (Release date: 2025-09-16)
footnote Full support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – Full support
Safari 18.4 (Release date: 2025-03-31)
footnote Full support
Firefox for Android – Full support
Firefox for Android 143 (Release date: 2025-09-16)
footnote
footnote Doesn't support the managed storage area.
footnote Data isn't synchronized with the user's Mozilla account in the sync storage area. See bug 1625257
Safari on iOS – Full support
Safari on iOS 18.4 (Release date: 2025-03-31)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.