document.hasPrivateToken() is an instance method that asks whether the browser already stores a private state token from a given issuer (see MDN Document: hasPrivateToken()). Learn the Promise boolean result, issuer URLs, secure-context rules, exceptions, and safe feature detection.
01
Kind
Instance method
02
Arg
issuer URL
03
Returns
Promise<boolean>
04
Context
Secure (HTTPS)
05
API
Private State Token
06
Status
Experimental
Fundamentals
Introduction
Private State Tokens help sites prove “this browser already completed a trust check with issuer X” without exposing a classic third-party cookie. Before requesting a new token, you can ask: do we already have one?
MDN: hasPrivateToken() returns a promise that fulfills with a boolean indicating whether the browser has a private state token stored from a particular issuer server.
💡
Think: “token already on file for this issuer?”
1) Feature-detect document.hasPrivateToken 2) Pass a valid issuer URL string 3) await the Promise → true / false 4) Only then decide whether to request a new token
🔒
Secure context required
MDN: NotAllowedError is thrown if the document is not loaded in a secure context. Use HTTPS (or localhost) when experimenting.
Examples follow MDN Document: hasPrivateToken() with beginner-safe feature detection. Many demos will report “not supported” outside Chromium.
📚 Getting Started
Detect support before calling the experimental method.
Example 1 — Feature-detect safely
Always check that the function exists before awaiting it.
JavaScript
if (typeof document.hasPrivateToken === "function") {
console.log("hasPrivateToken is available");
} else {
console.log("hasPrivateToken is not supported in this browser");
}
Document.hasPrivateToken() is Experimental on MDN. Support is primarily Chromium-based (Chrome / Edge from 117+, Opera from 103+). Firefox and Safari currently lack support. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Experimental · Limited
Document.hasPrivateToken()
Promise-based check for a stored private state token from an issuer URL. Feature-detect before use.
LimitedNot Baseline
Google Chrome117+
Yes
Microsoft Edge117+
Yes
Opera103+
Yes
Mozilla FirefoxNot supported
No
Apple SafariNot supported
No
Internet ExplorerNot supported
No
hasPrivateToken()Partial
Bottom line: Use only with feature detection and a fallback. Prefer learning this API for privacy experiments; do not assume universal browser support.
Wrap Up
Conclusion
document.hasPrivateToken(issuer) is an experimental instance method that resolves to whether a private state token from that issuer is already stored. Feature-detect, stay on HTTPS, pass a valid issuer URL, and treat support as limited.
Check first, then request issuance only if needed (MDN)
❌ Don’t
Ship without a fallback on unsupported browsers
Ignore the two-issuer-per-origin limit (MDN)
Pass relative or invalid issuer strings
Assume Firefox/Safari support today
Treat this as a Baseline everyday DOM API
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about hasPrivateToken()
Experimental issuer token presence check.
5
Core concepts
📝01
Returns
Promise<bool>
MDN
🔄02
Arg
issuer URL
MDN
🎯03
Secure
HTTPS
required
⚡04
Detect
typeof check
first
🛡05
Status
Experimental
MDN
❓ Frequently Asked Questions
MDN: Document.hasPrivateToken() returns a promise that fulfills with a boolean indicating whether the browser has a private state token stored from a particular issuer server.
MDN marks Document.hasPrivateToken() as Experimental. It is not Deprecated or Non-standard, but support is limited — check compatibility before production use.
MDN: issuer — a string representing the URL of an issuer server.
A boolean: true if a private state token from that issuer is stored; false otherwise (MDN).
MDN: InvalidStateError if the Document is not yet active; NotAllowedError if not in a secure context or the max issuers per top-level origin (two) is exceeded; TypeError if issuer is not a valid URL.
It is an instance method on Document (MDN page type). Call it as document.hasPrivateToken(issuer), and feature-detect with typeof document.hasPrivateToken === "function".
Did you know?
Private State Tokens grew out of the earlier “Trust Tokens” idea: prove that a browser completed an issuer check without sharing a long-lived cross-site identifier the way third-party cookies often did.