StorageArea.getBytesInUse()

Gets the amount of storage space, in bytes, used by one or more items stored in the storage area.

Note: In Firefox, this method is supported in:

Note: storage.managed.getBytesInUse() always returns 0, at least in Chrome and Firefox.

Syntax

js
let gettingSpace = browser.storage.<storageType>.getBytesInUse(
  keys                      // null, string, or array of strings
)

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

Parameters

keys

A key (string) or keys (an array of strings) to identify the items whose storage space you want to retrieve. If an empty array is passed in, 0 is returned. If you pass null or undefined, the function returns the space used by the entire storage area.

Return value

A Promise that is fulfilled with an integer, bytesUsed, representing the storage space used by the objects specified in keys. If the operation fails, the promise is rejected with an error message.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getBytesInUse
Chrome – Full support
Chrome 19 (Release date: 2012-05-15)
footnote Full support
Edge – Full support
Edge 14 (Release date: 2016-08-02)
footnote Full support
Firefox – Full support
Firefox 78 (Release date: 2020-06-30)
footnote
footnote Supported by the sync storage area from Firefox 78.
footnote Supported by the session storage area from Firefox 131.
footnote Supported by the local and managed storage areas from Firefox 144.
Opera – Full support
Opera 33 (Release date: 2015-10-27)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote
footnote Supported by the sync storage area from Firefox for Android 79.
footnote Supported by the session storage area from Firefox for Android 131.
footnote Supported by the local and managed storage areas from Firefox for Android 144.
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

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

Full support
Full support
See implementation notes.

Note: This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.