Asynchronously retrieve data from storage.sync, then cache it.Ĭonst initStorageCache = getAllStorageSyncData ( ). Where we will expose all the data we retrieve from storage.sync. To do this, the below snippet uses an async action.onClicked event handler that waits for the storageCache global to be populated before executing its logic. Since service workers are not always running, Manifest V3 extensions sometimes need to asynchronously load data from storage before they execute their event handlers. For example: ) # Asynchronous preload from storage You must declare the "storage" permission in the extension manifest to use the storage API. Enterprise policies configured by the administrator for the extension can be read (using storage.managed with a schema).User data can be stored as objects (the localStorage API stores data in strings).
It's asynchronous with bulk read and write operations, and therefore faster than the blocking and serial localStorage API.A user's extension settings can be persisted even when using split incognito behavior.Your extension's content scripts can directly access user data without the need for a background page.User data can be automatically synced with Chrome sync (using storage.sync).It provides the same storage capabilities as the localStorage API with the following key differences: Note that the getData method always returns an empty string in a handler for the ondragstart event in Safari and Google Chrome so the dropped text's letters won't be in reverse order. This API has been optimized to meet the specific storage needs of extensions. This example illustrates the use of the clearData, getData and setData methods.