JavaScript Navigator credentials Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline

What You’ll Learn

navigator.credentials returns a CredentialsContainer — the Credential Management API entry point. Learn feature detection, secure context rules, get() / store() / preventSilentAccess(), five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

CredentialsContainer

03

Baseline

Widely available

04

Context

Secure (HTTPS)

05

Retrieve

get()

06

Save

store()

Introduction

Modern browsers can help with sign-in: remember passwords, show an account chooser, and restore sessions more smoothly. The Credential Management API is how your page talks to that browser-managed credential store.

Your entry point is navigator.credentials. It is read-only and returns a CredentialsContainer with methods to request credentials and to notify the browser about successful sign-in or sign-out.

💡
Secure context required

MDN: available only in secure contexts (HTTPS / localhost). Feature-detect with "credentials" in navigator and keep a classic login form as fallback.

Understanding the credentials Property

Think of navigator.credentials as a handle to the browser’s credential manager for this document. You do not assign to it — you call methods on the object it returns.

  • get(options) — request a credential (for example password or federated).
  • store(credential) — ask the browser to save a credential after sign-in.
  • create(options) — create credential objects (varies by credential type).
  • preventSilentAccess() — after logout, stop automatic silent re-sign-in.

📝 Syntax

General form of the property:

JavaScript
navigator.credentials

Value

  • A CredentialsContainer object associated with the current document.

Common patterns

JavaScript
// MDN feature detect + get:
if ("credentials" in navigator) {
  navigator.credentials.get({ password: true }).then((creds) => {
    // Use creds, or null if the user cancelled / none found
  });
} else {
  // Classic sign-in form
}

// After logout:
await navigator.credentials.preventSilentAccess();

⚡ Quick Reference

GoalCode
Get CredentialsContainernavigator.credentials
Detect API"credentials" in navigator
Request password credsawait navigator.credentials.get({ password: true })
Store after loginawait navigator.credentials.store(cred)
After logoutawait navigator.credentials.preventSilentAccess()
Secure page?window.isSecureContext

🔍 At a Glance

Four facts to remember about navigator.credentials.

Returns
CredentialsContainer

API entry

Baseline
widely

Since ~2019

HTTPS
required

Secure context

Main call
get()

Request creds

📋 Credential Manager vs Classic Form

navigator.credentialsUsername / password form
UXBrowser chooser / autofill flowType credentials each time
StorageBrowser-managed credential storeYour server + optional password manager
SupportBaseline + HTTPSWorks everywhere
Best forSmoother return visitsAlways-available fallback
Use together?Yes — enhance sign-in when available; keep the form

Examples Gallery

Examples follow MDN Credential Management / navigator.credentials patterns. Prefer Try It Yourself over HTTPS. Use View Output for expected messaging.

📚 Getting Started

Detect the API and confirm a secure context.

Example 1 — Feature Detection

MDN-style check for Credential Management support.

JavaScript
const supported = "credentials" in navigator;
console.log(supported ? "credentials available" : "credentials missing");
Try It Yourself

How It Works

If the check fails, fall back to your normal sign-in form — MDN’s recommended pattern.

Example 2 — Secure Context Check

Pair detection with isSecureContext.

JavaScript
const lines = [
  "isSecureContext: " + window.isSecureContext,
  "credentials: " + (("credentials" in navigator) ? "present" : "absent")
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

Serve credential features over HTTPS (or localhost during development).

📈 Practical Patterns

Inspect the container, call get(), and handle logout.

Example 3 — Inspect CredentialsContainer

Confirm the object and which methods exist.

JavaScript
if (!("credentials" in navigator)) {
  console.log("unsupported");
} else {
  const c = navigator.credentials;
  const lines = [
    "type: " + (c && c.constructor && c.constructor.name),
    "get: " + (typeof c.get),
    "store: " + (typeof c.store),
    "preventSilentAccess: " + (typeof c.preventSilentAccess)
  ];
  console.log(lines.join("\n"));
}
Try It Yourself

How It Works

You always work through methods on this container — never by assigning to navigator.credentials.

Example 4 — get({ password: true })

MDN-style request for a stored password credential (from a button).

JavaScript
async function tryGetPasswordCred() {
  if (!("credentials" in navigator)) {
    return "credentials unavailable";
  }
  try {
    const creds = await navigator.credentials.get({ password: true });
    if (!creds) {
      return "no credential returned (cancelled or none saved)";
    }
    return "got credential type: " + creds.type + ", id: " + creds.id;
  } catch (err) {
    return "get failed: " + err.name;
  }
}

// Call from a button click in Try It
Try It Yourself

How It Works

get() resolves to a credential or null. Never log raw passwords in production tutorials or apps.

Example 5 — Logout Helper

After sign-out, call preventSilentAccess() so the browser does not auto sign-in again.

JavaScript
async function onLogout() {
  if (!window.isSecureContext) {
    return { ok: false, reason: "insecure-context" };
  }
  if (!("credentials" in navigator)) {
    return { ok: false, reason: "unsupported" };
  }
  try {
    await navigator.credentials.preventSilentAccess();
    return { ok: true, reason: "silent-access-prevented" };
  } catch (err) {
    return { ok: false, reason: err.name };
  }
}

// Call from a Logout button in Try It
Try It Yourself

How It Works

Pair this with clearing your own session cookies/tokens so logout is complete on both sides.

🚀 Common Use Cases

  • One-tap return visitsget() stored password or federated credentials.
  • Save after loginstore() so the browser remembers the account.
  • Clean logoutpreventSilentAccess() after the user signs out.
  • Passkeys / WebAuthn — related public-key flows also go through credential APIs (advanced).
  • Progressive enhancement — keep a normal form; upgrade when credentials exists.

🧠 How navigator.credentials Works

1

Secure page + detect

HTTPS / localhost and "credentials" in navigator.

Detect
2

Read CredentialsContainer

Use navigator.credentials as the API handle.

Entry
3

get / store / notify

Request credentials or save them after sign-in.

Action
4

Sign-in or fallback

Use returned creds, or show the classic form if null / unsupported.

📝 Notes

  • Baseline Widely available (MDN, since about September 2019).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Requires a secure context (HTTPS / localhost).
  • Never log or display passwords from credential objects in real apps.
  • Related: deviceMemory, Window, JavaScript hub.

Universal Browser Support

navigator.credentials is Baseline Widely available across modern browsers (MDN: since about September 2019). Always use a secure context. Keep a classic sign-in form when the API is missing or the user cancels.

Baseline · Widely available

Navigator.credentials

Feature-detect, call get/store over HTTPS, and use preventSilentAccess after logout.

Universal 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: Use navigator.credentials for Credential Management. Require HTTPS and always offer a normal login fallback.

Conclusion

navigator.credentials is the Credential Management API entry point. Feature-detect it, require HTTPS, use get() / store() thoughtfully, call preventSilentAccess() on logout, and keep a classic form as fallback.

Continue with deviceMemory, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect with "credentials" in navigator
  • Serve over HTTPS
  • Handle null from get() gracefully
  • Call preventSilentAccess() after logout
  • Keep a classic username/password form

❌ Don’t

  • Assume every user has a stored credential
  • Log passwords or secrets from credential objects
  • Skip secure-context checks
  • Rely on credentials alone without a server-side session
  • Forget to clear your own auth cookies on logout

Key Takeaways

Knowledge Unlocked

Five things to remember about credentials

Credential Management entry — get, store, and notify.

5
Core concepts
🔍 02

Retrieve

get()

Request
💾 03

Save

store()

Persist
🔒 04

HTTPS

secure context

Security
🚪 05

Logout

preventSilentAccess

Session

❓ 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.
Did you know?

MDN highlights that CredentialsContainer is also useful for feature detection — checking "credentials" in navigator tells you whether to offer the modern credential flow or stick to a classic form.

Learn deviceMemory Next

Approximate RAM hints for lighter experiences on low-memory devices.

deviceMemory →

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.

8 people found this page helpful