document.requestStorageAccess() is an instance method that lets third-party embeds ask for access to unpartitioned cookies and related state (see MDN Document: requestStorageAccess()). Learn the Storage Access flow, user-gesture rules, optional types / StorageAccessHandle, pairing with hasStorageAccess(), and five try-it labs.
01
Kind
Instance method
02
Returns
Promise
03
Context
3rd-party embed
04
Gesture
Often required
05
Secure
HTTPS needed
06
Status
Baseline
Fundamentals
Introduction
Modern browsers often block third-party cookies and partition storage so trackers cannot quietly follow users across sites. Embedded widgets (chat, login, payment, comments) sometimes still need their own site’s cookies when shown inside an <iframe>.
MDN: requestStorageAccess() lets that embed request access to third-party cookies and unpartitioned state. It is part of the Storage Access API. First check with hasStorageAccess(); if access is missing, call requestStorageAccess() from a user gesture.
💡
Think: “Ask the browser for my cookies inside this iframe”
1) Feature-detect the API 2) await document.hasStorageAccess() 3) If false, on a click/tap call requestStorageAccess() 4) On grant, reload the embed so cookies are sent (MDN)
⚠️
Top-level pages vs embeds
The main use case is third-party iframes. On a normal first-party page, try-it labs still teach the API shape, but grants/denials may not match a real cross-site embed. Always test inside the iframe scenario you ship.
typesOptional — an object controlling which unpartitioned state becomes accessible. Properties default to false when omitted. MDN lists flags such as all, cookies, sessionStorage, localStorage, indexedDB, locks, caches, getDirectory, estimate, createObjectURL, revokeObjectURL, BroadcastChannel, and SharedWorker.
Return value
A Promise that fulfills with undefined if third-party cookie access was granted and no types parameter was provided; fulfills with a StorageAccessHandle if types requested unpartitioned state; and rejects if access was denied (MDN).
Exceptions
InvalidStateErrorDOMException — Document not yet active, or types is provided with all properties false (MDN).
NotAllowedErrorDOMException — not a secure context, blocked by Permissions Policy, null origin, sandbox missing allow-storage-access-by-user-activation, or the user agent denies permission (MDN).
localStorage access granted
bar
(or localStorage access denied — support for types varies)
How It Works
When types is provided, a successful call resolves with a StorageAccessHandle instead of undefined (MDN). Passing types with every property false throws InvalidStateError.
Applications
🚀 Common Use Cases
Embedded login / SSO widgets — restore the embedder’s cookies inside an iframe (MDN use case).
Chat / comment / payment embeds — personalized state blocked by default third-party cookie rules.
Storage Access flow — check with hasStorageAccess(), then request on click (MDN).
Unpartitioned storage — request localStorage / indexedDB via types where supported (MDN).
Document.requestStorageAccess() is Baseline Widely available on MDN (since December 2023). Some parts of this feature may have varying levels of support (for example optional types). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Document.requestStorageAccess()
Storage Access API request for third-party unpartitioned cookies and related state in embeds.
BaselineWidely available
Google Chrome119+
Yes
Mozilla Firefox65+
Yes
Apple Safari11.1+
Yes
Microsoft Edge85+
Yes
Opera105+
Yes
Internet ExplorerNot supported
No
requestStorageAccess()Wide
Bottom line: Call from a user gesture in third-party iframes after hasStorageAccess() is false. Reload on grant, and always handle denial gracefully.
Wrap Up
Conclusion
document.requestStorageAccess() is how third-party embeds ask for unpartitioned cookie (and related) access under the Storage Access API. Check first with hasStorageAccess(), request from a user gesture, reload on grant, and design a clear fallback when the Promise rejects.
Treat a top-level demo as proof for cross-site iframes
Skip error handling for cookie / storage failures
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about requestStorageAccess()
Baseline Storage Access request for third-party embeds.
5
Core concepts
📝01
Returns
Promise
MDN
🔓02
Gesture
often needed
MDN
🔍03
Check
hasStorageAccess
first
🔄04
Grant
reload embed
MDN
🛡05
Status
Baseline
2023
❓ Frequently Asked Questions
MDN: Document.requestStorageAccess() lets content loaded in a third-party context (for example an iframe) request access to third-party cookies and unpartitioned state. It is part of the Storage Access API.
No. MDN marks Document.requestStorageAccess() as Baseline Widely available (across browsers since December 2023). Some parts of the feature may have varying support. It is not Deprecated, Experimental, or Non-standard.
Yes in the common case. MDN: requests are automatically denied unless the embed is processing a user gesture (transient activation), or permission was already granted previously.
MDN: fulfills with undefined if cookie access was granted and no types parameter was provided; fulfills with a StorageAccessHandle if types requested unpartitioned state; rejects if access was denied.
Call document.hasStorageAccess() (or hasUnpartitionedCookieAccess()). You can also use Permissions.query() with the feature name "storage-access" (MDN).
MDN: after an embed activates storage-access permission via requestStorageAccess(), it should reload itself so the browser re-requests the resource with third-party unpartitioned cookies included.
Did you know?
MDN points out that when the Promise rejects, the user gesture is deliberately consumed. That stops malicious pages from calling requestStorageAccess() in a tight loop until the user gives up and accepts a permission prompt.