How to clear chrome.storage.local and chrome.storage.sync?

Use chrome.storage.local.clear() and chrome.storage.sync.clear()

The API is asynchronous so to do subsequent actions to the storage, use a callback:

chrome.storage.local.clear(function() {
    var error = chrome.runtime.lastError;
    if (error) {
        console.error(error);
    }
    // do something more
});
chrome.storage.sync.clear(); // callback is optional

Leave a Comment