MDN self-hosted library · e01.org

StorageAccessHandle: localStorage property

Storage Access API

Open notebook · 1 cells web-api-instance-property upstream source

Storage Access API

The localStorage property of the StorageAccessHandle interface returns an unpartitioned local Storage object if access was granted, and throws a SecurityError DOMException otherwise.

Value

A Storage object.

Examples

document.requestStorageAccess({ localStorage: true }).then(
  (handle) => {
    console.log("localStorage access granted");
    handle.localStorage.setItem("foo", "bar");
  },
  () => {
    console.log("localStorage access denied");
  },
);

[!NOTE] See Using the Storage Access API for a more complete example.

Specifications

Browser compatibility

See also