JavaScript Navigator login Property

Beginner
5 min read
Updated: Nov 2026
5 examples
Property

Definition

navigator.login is a read-only Navigator property that returns a NavigatorLogin object (MDN). A federated identity provider (IdP) uses it to tell the browser whether any users are signed into the IdP — part of the Login Status API for FedCM.

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

Syntax

Use navigator.login. Start with this line.

JavaScript
navigator.login
CallWhat it does
navigator.loginPrimary signature.

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

Library declarations
JavaScript
navigator.login

Parameters

ParameterDescription
setStatus(status)Required. Report IdP login state to the browser
"logged-in" / "logged-out"Required. Only allowed status strings

Return Value

Return ValueDescription
*Promise<undefined>

JavaScript Examples

Example 1 — Feature Detection

Check whether navigator.login is exposed before calling setStatus.

JavaScript
const supported = Boolean(navigator.login);
console.log(
  supported ? "Login Status API available" : "Login Status API missing"
);
Try It Yourself

How It Works

  1. Read the property. Unsupported browsers leave it undefined.
  2. Coerce to Boolean. A clear yes/no for branching.
  3. Skip when missing. IdP sites can still run without FedCM status.
  4. Still check HTTPS. Presence alone is not enough on insecure pages.

Example 2 — Secure Context Check

Confirm HTTPS / localhost together with navigator.login.

JavaScript
const lines = [
  "secure: " + window.isSecureContext,
  "login: " + Boolean(navigator.login)
];

if (!window.isSecureContext) {
  lines.push("Serve over HTTPS to use navigator.login");
} else if (!navigator.login) {
  lines.push("Secure, but Login Status API not exposed");
} else {
  lines.push("Ready to call setStatus");
}

console.log(lines.join("\n"));
Try It Yourself

How It Works

  1. Check isSecureContext. MDN requires a secure context.
  2. Check the property. Limited browsers may still omit the API.
  3. Print a clear hint. Helps debug http:// vs https://.
  4. Call methods only when ready. Avoids confusing errors.

Example 3 — setStatus("logged-in") (MDN)

Tell the browser that at least one IdP account is signed in.

JavaScript
async function markLoggedIn() {
  if (!navigator.login) return "Login Status API not supported.";
  await navigator.login.setStatus("logged-in");
  return "status set: logged-in";
}

markLoggedIn().then(console.log).catch((err) => {
  console.log((err.name || "Error") + ": " + (err.message || err));
});
Try It Yourself

How It Works

  1. Guard first. Skip when navigator.login is missing.
  2. Pass "logged-in". Means ≥1 IdP account is signed in.
  3. Await the Promise. Resolves with undefined on success.
  4. Catch errors. Cross-origin iframe nesting can throw SecurityError.

Example 4 — setStatus("logged-out") (MDN)

Tell the browser that all IdP accounts are signed out.

JavaScript
async function markLoggedOut() {
  if (!navigator.login) return "Login Status API not supported.";
  await navigator.login.setStatus("logged-out");
  return "status set: logged-out";
}

markLoggedOut().then(console.log).catch((err) => {
  console.log((err.name || "Error") + ": " + (err.message || err));
});
Try It Yourself

How It Works

  1. Call after full logout. All IdP accounts must be signed out.
  2. Pass "logged-out". FedCM can skip account fetches.
  3. Await completion. Same Promise pattern as logged-in.
  4. Handle failure. Soft-fail so logout UX still works without the API.

Example 5 — Safe IdP Status Helper

Wrap detect + setStatus + errors in one small helper.

JavaScript
async function setIdpLoginStatus(status) {
  if (!navigator.login || typeof navigator.login.setStatus !== "function") {
    return { ok: false, reason: "unsupported" };
  }
  try {
    await navigator.login.setStatus(status);
    return { ok: true, status: status };
  } catch (err) {
    return {
      ok: false,
      reason: String(err.name || "Error"),
      message: String(err.message || err)
    };
  }
}

setIdpLoginStatus("logged-in").then((r) =>
  console.log(JSON.stringify(r, null, 2))
);
Try It Yourself

How It Works

  1. Detect method + property. Double-check setStatus is a function.
  2. Try / catch. Convert thrown errors into a plain result object.
  3. Return structured status. Easy to log or show in IdP UI.
  4. Reuse for both statuses. Pass "logged-in" or "logged-out".

Browser Support

navigator.login is part of the Login Status API for FedCM. Support is limited — feature-detect and require a secure context.

✓ Limited availability · Secure context

Navigator.login

Available in supporting Chromium-based browsers on HTTPS. Often missing in Safari. Always detect before calling setStatus.

55% Modern browser support
Google Chrome Login Status · secure context
Limited
Microsoft Edge Follow Chromium FedCM / Login Status
Limited
Opera Follow Chromium when exposed
Limited
Mozilla Firefox Check current FedCM / Login Status support
Limited
Apple Safari Often unavailable
Unavailable
Internet Explorer No Login Status / navigator.login
Unavailable
navigator.login Limited

Bottom line: Treat Login Status as progressive enhancement for IdP sites. Soft-fail when the API is missing so sign-in and sign-out still work.

Frequently Asked Questions

A read-only NavigatorLogin object so a federated identity provider (IdP) can tell the browser whether any users are logged into the IdP (Login Status API / FedCM).
MDN does not mark it Deprecated, Experimental, or Non-standard. Support is still limited (often missing in Safari). Always feature-detect and require a secure context.
The IdP site — after a user signs in or out on the IdP’s own origin. Relying parties (websites that use “Sign in with …”) do not use this to log users into their own app.
"logged-in" means at least one user account is signed in at the IdP. "logged-out" means all IdP accounts are signed out.
So the browser can skip useless account requests when nobody is logged into the IdP, and to help mitigate timing attacks related to federated sign-in.
Yes. It is available only in secure contexts (HTTPS or localhost). setStatus also requires same-origin framing rules when used inside iframes.

Next: maxTouchPoints

Learn how navigator.maxTouchPoints reports simultaneous touch capacity.

maxTouchPoints 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.

9 people found this page helpful