Navigator: credentials プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

credentialsNavigator インターフェイスのプロパティで、リクエストの資格情報のメソッドを公開する CredentialsContainer インターフェイスを返します。 CredentialsContainer インターフェイスはログインやログアウトに成功した場合など、興味深いイベントが発生したことをユーザーエージェントに通知したりもします。このインターフェイスは機能検出に使用することができます。

CredentialsContainer インターフェイスです。

js
if ("credentials" in navigator) {
  navigator.credentials.get({ password: true }).then((creds) => {
    //資格情報付きで何かを行う
  });
} else {
  // 以前の方法でログインを扱う
}

仕様書

Specification
Credential Management Level 1
# framework-credential-management

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
credentials

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support