document.hasPrivateToken(issuer) returns a Promise that fulfills with a boolean: whether the browser already has a private state token from that issuer server (MDN).
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call document.hasPrivateToken. Start with this line.
JavaScript
document.hasPrivateToken(issuer)
Call
What it does
document.hasPrivateToken(issuer)
Primary signature.
document.hasPrivateToken(...)
Call with the arguments your case needs.
Built into the browser. Call hasPrivateToken(...) on document — no import required.
Library declarations
JavaScript
document.hasPrivateToken(issuer)
Parameters
Parameter
Description
issuer
Required. URL of the issuer server (MDN)
Secure context
Required. Required; else NotAllowedError
Return Value
Return Value
Description
*
Promise that resolves to boolean
JavaScript Examples
Example 1 — Feature-Detect First
Experimental APIs must be detected before you call them.
Detect first. Unsupported engines never throw from this call.
Pass a bad string. Not a valid URL → rejection (MDN TypeError).
Catch the error. Read err.name for a clear student-friendly log.
Other failures. Also watch for NotAllowedError / InvalidStateError (MDN).
Compatibility
Limited / Experimental Browser Support
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.
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.
Feature-detect with typeof document.hasPrivateToken === "function", use HTTPS (secure context), pass a valid issuer URL, and await the Promise (or use .then).