MDN self-hosted library · e01.org

Navigator: credentials property

Credential Management API

Open notebook · 1 cells web-api-instance-property upstream source

Credential Management API

The credentials read-only property of the Navigator interface returns the CredentialsContainer object associated with the current document, which exposes methods to request credentials. The CredentialsContainer interface also notifies the user agent when an interesting event occurs, such as a successful sign-in or sign-out. This interface can be used for feature detection.

Value

A CredentialsContainer object.

Examples

if ("credentials" in navigator) {
  navigator.credentials.get({ password: true }).then((creds) => {
    // Do something with the credentials.
  });
} else {
  // Handle sign-in the way you did before.
}

Specifications

Browser compatibility