Syntax

js
persisted()

Parameters

None.

Return value

Exceptions

TypeError

Thrown if obtaining a local storage shelf failed. For example, if the current origin is an opaque origin or if the user has disabled storage.

Example

js
if (navigator.storage && navigator.storage.persist) {
  navigator.storage.persisted().then((persistent) => {
    if (persistent) {
      console.log("Storage will not be cleared except by explicit user action");
    } else {
      console.log("Storage may be cleared by the UA under storage pressure.");
    }
  });
}

Specifications

Specification
Product help
  • persist()
  • WorkerNavigator.storage
  • ","source":{"folder":"en-us/web/api/storagemanager/persisted","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/storagemanager/persisted/index.md","last_commit_url":"https://github.com/mdn/content/commit/8ac73df2fbe2c88d8649fcb006dcde098616c723","filename":"index.md"},"summary":"The persisted() method of the StorageManager interface returns a Promise that resolves to true if your site's storage bucket is persistent.","title":"StorageManager: persisted() method","toc":[{"text":"Syntax","id":"syntax"},{"text":"Example","id":"example"},{"text":"Specifications","id":"specifications"},{"text":"Browser compatibility","id":"browser_compatibility"}],"browserCompat":["api.StorageManager.persisted"],"pageType":"web-api-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant