Stores one or more items in the storage area, or update existing items.

When you store or update a value using this API, the storage.onChanged event will fire.

This is an asynchronous function that returns a Promise.


let settingItem =<storageType>.set(
  keys             // object

<storageType> will be one of the writable storage types — storage.sync or storage.local.


An object containing one or more key/value pairs to be stored in storage. If an item already exists, its value will be updated.
  • Primitive values (such as numbers) and arrays will serialize as expected.
  • Functions will be omitted.
  • Dates, and Regexes will serialize using their String representation.

Return value

A Promise that will be fulfilled with no arguments if the operation succeeded. If the operation failed, the promise will be rejected with an error message.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes 145.048.033
1. storage is limited to 1MB per value.


function onError(error) {
  console.log(`Error: ${error}`);

// Define 2 objects, that contain: a string, a function, a Date
// Note that the function will not be stored.
let monster = {
  name: "Kraken",
  speak: function() {console.log("ROARR!!!")},
  birthday: new Date(2012, 11, 17)

let kitten = {
  name: "Moggy",
  speak: function() {console.log("Miaow")},
  birthday: new Date(2006, 7, 12)

// store the objects
let setting ={kitten, monster});
// just check for errors
setting.then(null, onError);


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

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, jonathanKingston, Makyen, chrisdavidmills
 Last updated by: wbamberg,