JavaScript Navigator login Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Limited support
Secure context

What You’ll Learn

navigator.login is the entry point for the Login Status API used by federated identity providers. Learn NavigatorLogin.setStatus, FedCM context, secure context rules, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

NavigatorLogin

03

API

Login Status

04

Context

Secure (HTTPS)

05

Method

setStatus()

06

Values

logged-in / out

Introduction

Federated sign-in (“Sign in with …”) involves an identity provider (IdP) and a relying party (RP) website. The browser’s FedCM flow needs to know whether anyone is actually signed into the IdP before asking for accounts.

navigator.login returns a NavigatorLogin object. On the IdP’s own site, after login or logout, you call setStatus("logged-in") or setStatus("logged-out") so the browser can store that IdP login status.

💡
IdP API, not your app’s session

This does not replace cookies or tokens for your own website login. It tells the browser about the IdP’s signed-in state for FedCM. Regular apps keep using their normal auth stack (and often navigator.credentials).

Understanding the login Property

Think of navigator.login as a signal light the IdP flips for the browser: “someone is logged in here” vs “everyone is logged out.”

  • NavigatorLogin — object returned by navigator.login.
  • setStatus(status) — IdP reports login status to the browser.
  • "logged-in" — at least one IdP account is signed in.
  • "logged-out" — all IdP accounts are signed out.
  • FedCM — uses the signal to avoid useless account requests.
  • Secure context — HTTPS / localhost; same-origin iframe rules apply.

📝 Syntax

General form of the property:

JavaScript
navigator.login

Value

  • A NavigatorLogin object when the Login Status API is available.

Common patterns

JavaScript
// MDN examples — call from the IdP origin after auth changes:
navigator.login.setStatus("logged-in");
navigator.login.setStatus("logged-out");

// Safe feature-detect + await:
if (navigator.login && typeof navigator.login.setStatus === "function") {
  await navigator.login.setStatus("logged-in");
}

⚡ Quick Reference

GoalCode
Get Login Status APInavigator.login
Detect APIBoolean(navigator.login)
Signal signed inawait navigator.login.setStatus("logged-in")
Signal signed outawait navigator.login.setStatus("logged-out")
Secure page?window.isSecureContext
RelatedFedCM / IdP integration

🔍 At a Glance

Four facts to remember about navigator.login.

Returns
NavigatorLogin

IdP helper

Method
setStatus()

Promise

HTTPS
required

Secure context

Audience
IdP sites

FedCM

📋 login vs credentials

navigator.loginnavigator.credentials
PurposeTell browser IdP login statusGet/store user credentials
Typical callerIdentity provider (IdP)Any site with a sign-in form
Key methodsetStatus()get() / store()
FedCM roleLogin Status signalSeparate credential flows
Replaces your session?NoNo — still need server auth

Examples Gallery

Examples follow MDN Login Status / navigator.login.setStatus patterns. Prefer Try It Yourself on HTTPS. Real FedCM value appears when called from an IdP origin after login/logout.

📚 Getting Started

Detect the API and confirm a secure context.

Example 1 — Feature Detection

Check whether the Login Status entry point exists.

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

How It Works

Safari typically omits this API today — always keep a non-FedCM path.

Example 2 — Secure Context Check

Login Status requires HTTPS / localhost.

JavaScript
console.log("secure: " + window.isSecureContext);
console.log("login: " + Boolean(navigator.login));

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

How It Works

Even on HTTPS, missing navigator.login means the browser does not expose Login Status yet.

📈 Practical Patterns

Set logged-in / logged-out and wrap calls safely.

Example 3 — Set logged-in

MDN pattern after a successful IdP sign-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(String(err.name || "Error") + ": " + (err.message || err));
});
Try It Yourself

How It Works

Call this on the IdP origin right after the user finishes signing in.

Example 4 — Set logged-out

MDN pattern when 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(String(err.name || "Error") + ": " + (err.message || err));
});
Try It Yourself

How It Works

Call this after logout on the IdP so FedCM knows not to expect accounts.

Example 5 — IdP Status Helper

Wrap detection and setStatus for IdP login/logout handlers.

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)));
Try It Yourself

How It Works

MDN notes SecurityError if called from a cross-origin nested iframe hierarchy — catch errors in real IdP pages.

🚀 Common Use Cases

  • IdP sign-in successsetStatus("logged-in") after auth completes.
  • IdP logoutsetStatus("logged-out") when no accounts remain.
  • FedCM readiness — help the browser skip empty account fetches.
  • Privacy / timing — reduce signals that enable timing attacks (FedCM design goal).
  • HTTP alternative — some flows also use a Set-Login response header (see FedCM docs).

🧠 How navigator.login Works

1

User signs in or out at the IdP

On the identity provider’s own origin.

Auth
2

IdP calls setStatus

navigator.login.setStatus("logged-in"|"logged-out").

Signal
3

Browser stores IdP status

Used later by FedCM for that provider.

Store
4

RP FedCM flows get smarter

Fewer useless account requests when the IdP is logged out.

📝 Notes

  • Not Deprecated, Experimental, or Non-standard on MDN — no status banner on this page.
  • Limited availability (e.g. Safari typically unsupported) — always feature-detect.
  • Secure context required (HTTPS / localhost).
  • Intended for IdP origins used with the FedCM / Login Status API.
  • Related: maxTouchPoints, credentials, JavaScript hub.

Limited Browser Support

navigator.login (Login Status API) requires a secure context and is not universal. Chromium and Firefox have shipped support; Safari typically has not. Always feature-detect.

Limited · Secure context

Navigator.login

IdP sites call setStatus after login/logout so FedCM knows whether accounts may exist.

Limited Not universal
Google Chrome Login Status / navigator.login since ~120 (secure context)
Supported
Microsoft Edge Chromium Edge — follows Chrome Login Status support
Supported
Opera Chromium-based — Login Status where Chromium enables it
Supported
Mozilla Firefox navigator.login since ~138 — verify on target versions
Supported*
Apple Safari Typically unavailable — check current MDN
Unavailable
login Limited

Bottom line: Detect navigator.login over HTTPS. Call setStatus only from the IdP origin after real auth changes.

Conclusion

navigator.login is the Login Status API entry point for identity providers. Feature-detect it in a secure context, call setStatus("logged-in") or "logged-out" from the IdP origin after auth changes, and keep FedCM as an enhancement — not your only auth path.

Continue with maxTouchPoints, credentials, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Call setStatus from the IdP origin
  • Update status after real login and logout
  • Feature-detect and catch SecurityError
  • Serve over HTTPS
  • Read FedCM IdP integration docs for full setup

❌ Don’t

  • Use it as your app’s only session API
  • Assume Safari supports it
  • Call from arbitrary cross-origin iframes
  • Forget to signal logout
  • Confuse it with navigator.credentials

Key Takeaways

Knowledge Unlocked

Five things to remember about login

IdP Login Status signal for FedCM — setStatus after auth changes.

5
Core concepts
👤 02

Caller

IdP origin

FedCM
🔒 03

Method

setStatus

Signal
🔓 04

Values

in / out

Status
🔬 05

Support

Limited

Detect

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a NavigatorLogin object so a federated identity provider (IdP) can tell the browser whether users are logged into the IdP.
MDN/BCD does not mark it Deprecated, Experimental, or Non-standard. Support is still limited (notably 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.
Did you know?

MDN’s wording for login status is carefully narrow: it means whether any users are logged into the IdP in this browser — not which account, and not whether the relying party website has a session.

Explore maxTouchPoints Next

Learn how many simultaneous touch contacts the device can track.

maxTouchPoints →

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