JavaScript Navigator credentials Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.credentials is a read-only property that returns a CredentialsContainer for the current document (MDN) — the entry point to the Credential Management API for requesting and storing sign-in credentials.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.credentials. Start with this line.

JavaScript
navigator.credentials
CallWhat it does
navigator.credentialsPrimary signature.

Built into the browser. Read navigator.credentials on Navigator — no import required.

Library declarations
JavaScript
navigator.credentials

Parameters

ParameterDescription
"credentials" in navigatorRequired. Feature detect
Secure contextRequired. HTTPS or localhost

Return Value

Return ValueDescription
*CredentialsContainer (read-only property)

JavaScript Examples

Example 1 — Feature Detect

MDN’s support check, plus secure context.

JavaScript
const hasCreds = "credentials" in navigator;
const secure = window.isSecureContext;

console.log("credentials:", hasCreds);
console.log("secure context:", secure);

if (hasCreds && secure) {
  console.log("ready for Credential Management API");
} else {
  console.log("use classic sign-in");
}
Try It Yourself

How It Works

  1. Use in. MDN checks "credentials" in navigator.
  2. Check HTTPS. The API needs a secure context.
  3. Fallback. If either fails, keep a classic login form.
  4. No prompt yet. Detection alone does not open a credential UI.

Example 2 — get() Pattern

Request password credentials when the API exists (handle cancel).

JavaScript
async function tryCredentialLogin() {
  if (!("credentials" in navigator)) {
    console.log("credentials missing — classic form");
    return;
  }
  try {
    const creds = await navigator.credentials.get({ password: true });
    if (creds) {
      console.log("got credential type:", creds.type);
    } else {
      console.log("no credential returned");
    }
  } catch (err) {
    console.log("get failed:", err.name);
  }
}

// Prefer calling from a user gesture (button click).
Try It Yourself

How It Works

  1. Detect first. Skip when the API is absent.
  2. Await get. Pass options such as { password: true }.
  3. Handle null. No stored match / cancel → show a form.
  4. Catch errors. Permissions or policy can reject the Promise.

Example 3 — preventSilentAccess() After Logout

Stop automatic silent sign-in on the next visit.

JavaScript
async function afterLogout() {
  // … clear your app session …

  if ("credentials" in navigator && navigator.credentials.preventSilentAccess) {
    try {
      await navigator.credentials.preventSilentAccess();
      console.log("silent access prevented");
    } catch (err) {
      console.log("preventSilentAccess failed:", err.name);
    }
  }
}

afterLogout();
Try It Yourself

How It Works

  1. Clear your session. Log the user out in your app first.
  2. Call preventSilentAccess. Tells the UA not to auto-login silently next time.
  3. Await the Promise. Resolves when the flag is set.
  4. Optional API. Check the method exists before calling.

Browser Support

navigator.credentials is marked Baseline Widely available on MDN (since September 2019). Secure context is required. Some CredentialsContainer methods/options still vary.

✓ Baseline · Widely available

Navigator.credentials

Returns CredentialsContainer for get/store/create/preventSilentAccess. Feature-detect; keep a classic login fallback.

100% Widely available
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
credentials Excellent

Bottom line: Safe to use on HTTPS as progressive enhancement for password / credential UX. Always provide a classic sign-in path.

Frequently Asked Questions

It is a read-only Navigator property that returns a CredentialsContainer for the current document — the entry point to the Credential Management API for requesting, storing, and managing sign-in credentials.
No. MDN marks it Baseline Widely available (since about September 2019). It is not Deprecated, Experimental, or Non-standard. It does require a secure context (HTTPS / localhost).
MDN's pattern: if ("credentials" in navigator) { /* use CredentialsContainer */ } else { /* classic sign-in */ }.
Common methods include get() to retrieve credentials, store() to save them, create() to build credential objects, and preventSilentAccess() to stop automatic silent sign-in after logout.
Yes. The API is available only in secure contexts in supporting browsers.
No. The property is read-only. You call methods on the returned CredentialsContainer object.

Next: deviceMemory

Learn the related Navigator deviceMemory property.

deviceMemory tutorial →

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.

7 people found this page helpful