JavaScript Document hasStorageAccess() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

document.hasStorageAccess() returns a Promise that resolves to a boolean: whether this document has access to third-party, unpartitioned cookies (MDN). It is part of the Storage Access API and takes no parameters.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call document.hasStorageAccess. Start with this line.

JavaScript
document.hasStorageAccess()
CallWhat it does
document.hasStorageAccess()Primary signature.
document.hasStorageAccess(...)Call with the arguments your case needs.

Built into the browser. Call hasStorageAccess(...) on document — no import required.

Library declarations
JavaScript
document.hasStorageAccess()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Promise resolving to boolean

JavaScript Examples

Example 1 — Await the Boolean

Call hasStorageAccess() and log whether access is granted.

JavaScript
document.hasStorageAccess().then((hasAccess) => {
  console.log(hasAccess);
  console.log(typeof hasAccess); // "boolean"
});
Try It Yourself

How It Works

  1. Call with no args. MDN: the method takes no parameters.
  2. Get a Promise. It resolves to a boolean, not a string.
  3. Read the flag. true means unpartitioned cookie access is reported as granted.
  4. Context matters. Top-level pages often see true; third-party iframes vary.

Example 2 — Branch Like MDN

Granted already vs consider requestStorageAccess().

JavaScript
document.hasStorageAccess().then((hasAccess) => {
  if (hasAccess) {
    console.log("cookie access granted");
  } else {
    console.log("cookie access denied");
    // you may want to call requestStorageAccess() (MDN)
  }
});
Try It Yourself

How It Works

  1. Await the check. Same Promise as Example 1.
  2. If true. MDN: access has been granted already.
  3. If false. MDN: you may call requestStorageAccess().
  4. User gesture tip. MDN: if called during a gesture, the resolve handler can keep user-activation for APIs that need it.

Example 3 — Same Idea as the Newer Name

MDN: hasStorageAccess() is another name for hasUnpartitionedCookieAccess().

JavaScript
async function compareNames() {
  const a = await document.hasStorageAccess();
  const hasAlias = typeof document.hasUnpartitionedCookieAccess === "function";
  if (!hasAlias) return { a, alias: "missing" };
  const b = await document.hasUnpartitionedCookieAccess();
  return { a, b, same: a === b };
}

compareNames().then(console.log);
Try It Yourself

How It Works

  1. Call the classic name. hasStorageAccess() is Baseline and widely taught.
  2. Detect the alias. Newer engines also expose hasUnpartitionedCookieAccess().
  3. Compare booleans. When both exist, they should agree (same meaning, MDN).
  4. No removal plan. MDN: hasStorageAccess() is not being removed for the newer name.

Browser Support

Document.hasStorageAccess() is Baseline Widely available on MDN (since December 2023). Logos use the shared browser-image-sprite.png sprite from this project.

✓ Baseline Widely available

Document.hasStorageAccess()

Promise-based check for third-party unpartitioned cookie access across modern browsers.

Baseline Widely available
Google Chrome Supported
Yes
Mozilla Firefox Supported
Yes
Apple Safari Supported
Yes
Microsoft Edge Supported
Yes
Opera Supported
Yes
Internet Explorer Not supported
No
hasStorageAccess() Wide

Bottom line: Safe for Storage Access API flows in modern browsers. Still treat the boolean as a hint and handle cookie failures. See the MDN Document.hasStorageAccess() reference.

Frequently Asked Questions

MDN: Document.hasStorageAccess() returns a Promise that resolves with a boolean indicating whether the document has access to third-party, unpartitioned cookies. It is part of the Storage Access API.
No. MDN marks Document.hasStorageAccess() as Baseline Widely available (since December 2023). It is not Deprecated, Experimental, or Non-standard.
No. MDN: hasStorageAccess() takes no parameters.
MDN example: storage access has not been granted already; you may want to call document.requestStorageAccess().
Not always. MDN notes user settings may block third-party cookies even when true is returned, and some browsers may return false even when cookies are still accessible. Handle cookie errors gracefully and optionally probe document.cookie.
MDN: hasStorageAccess() is another name for Document.hasUnpartitionedCookieAccess(). There are no current plans to remove hasStorageAccess() in favor of the newer name.

Next: hasUnpartitionedCookieAccess()

Learn the newer alias name for the same Storage Access API check.

hasUnpartitionedCookieAccess() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful