@capgo/capacitor-autofill-save-password

中文文档
8.2.3发布于 2026/10/19MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 7.5万

Prompt to display dialog for saving password to keychain from webview app

原始使用文档
文档目录14 节
  1. ➡️ Get started for free
  2. Key features
  3. Documentation
  4. Compatibility
  5. Install
  6. Prerequisite
  7. How to use
  8. Android
  9. iOS
  10. API
  11. promptDialog(...)
  12. readPassword()
  13. getPluginVersion()
  14. Interfaces

@capgo/capacitor-autofill-save-password

Show the native save password prompt after login in your Capacitor app, so credentials land in the user's password manager, such as iCloud Keychain or Google Password Manager. Users sign in faster next time with autofill.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-autofill-save-password in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-autofill-save-password to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-autofill-save-password for Capacitor apps

Key features

  • Save prompt: promptDialog() asks the OS to save the username and password.
  • Read back: readPassword() lets the user pick a saved password for your app.
  • iOS: uses AuthenticationServices. On iOS 26.2 and later the credential goes to the user's chosen credential provider through ASCredentialDataManager.
  • Android: uses the AndroidX Credential Manager.
  • Platforms: iOS and Android. Not available on web.

Prompt to display dialog for saving password to keychain from webview app

Fork of original plugin to work with Capacitor 7+

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/autofill-save-password/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-autofill-save-password` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-autofill-save-password
npx cap sync

Prerequisite

You must set up your app’s associated domains. To learn how to set up your app’s associated domains, see Supporting Associated Domains in Apple Developer document.

Then add in your App.entitlements

    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>webcredentials:YOURDOMAIN</string>
    </array>

To associate your domain to your app.

How to use

import { Capacitor } from '@capacitor/core';
import { SavePassword } from '@capgo/capacitor-autofill-save-password';
    
login(username: string, password: string) {
    // your login logic here
        
        SavePassword.promptDialog({
            username: username,
            password: password,
        })
        .then(() => console.log('promptDialog success'))
        .catch((err) => console.error('promptDialog failure', err));
}

Android

Add apply plugin: 'com.google.gms.google-services' beneath apply plugin: 'com.android.application' in android/app/build.gradle

this will allow the plugin to import the proper lib.

Then you need to make sure you did set properly your domain and did add google-services.json.

guide here https://developer.android.com/identity/sign-in/credential-manager

You need to have the file at this path android/google-services.json set, if you dont use firebase add empty json

then add your domain in example-app/android/app/src/main/res/values/strings.xml

with

    <string name="asset_statements" translatable="false">
    [{
    \"include\": \"https://YOURDOMAIN/.well-known/assetlinks.json\"
    }]
    </string>

iOS

On iOS 26.2 and later, promptDialog saves through ASCredentialDataManager, which routes the save to whichever credential provider the user has chosen, iCloud Keychain or a third-party manager. Below 26.2 it falls back to SecAddSharedWebCredential, which Apple deprecated in 26.2 and which only ever writes to iCloud Keychain.

Either way the url option names the domain the credential is saved against, and it must be one of the webcredentials: associated domains you set up above.

Note the two paths differ in what they report back. SecAddSharedWebCredential surfaces a dismissed prompt as an error, so promptDialog rejects. ASCredentialDataManager only throws when the system rejects the update, Apple describe it as equivalent to submitting a password form, so the user's choice never reaches the app. On 26.2 and later, treat a resolved promise as "the system accepted the request", not as confirmation that the password was saved.

On 26.2 and later you can also pass title to control the name the credential is filed under. Without it the password manager falls back to the bare domain, so users see app.example.com rather than your product name. The old API has no equivalent, so title is ignored below 26.2.

API

promptDialog(...)

promptDialog(options: Options) => Promise<void>

Save a password to the keychain.

On iOS 26.2 and later, resolving means the system accepted the request — not that the credential was stored. The save prompt belongs to the system and the user's choice is not reported back, so do not treat a resolved promise as confirmation. Below 26.2, and on Android, dismissing the prompt rejects.

ParamTypeDescription
optionsOptions- The options for the password.

readPassword()

readPassword() => Promise<ReadPasswordResult>

Read a password from the keychain. Requires the developer to setup associated domain for the app for iOS.

Returns: Promise<ReadPasswordResult>


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 1.0.0


Interfaces

Options

PropTypeDescription
usernamestringThe username to save.
passwordstringThe password to save.
urlstringThe url to save the password for. (For example: "console.capgo.app") iOS only.
titlestringThe name the credential is filed under in the password manager. (For example: "Capgo"). Defaults to the domain from url. iOS 26.2 and later only.

ReadPasswordResult

PropTypeDescription
usernamestringThe username of the password.
passwordstringThe password of the password.

版本与发布记录

@capgo/capacitor-autofill-save-password 共发布 70 个版本,首次发布于 2025/05/21;过去 12 个月发布了 51 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.2.3latest2026/10/1920 天前
8.2.22026/10/1525 天前
8.2.12026/10/1327 天前
8.2.02026/10/091 个月前
8.1.52026/10/081 个月前
8.1.42026/09/221 个月前

其他发布通道:lts-v6 → 6.0.2。

关于 @capgo/capacitor-autofill-save-password 的常见问题

@capgo/capacitor-autofill-save-password 是什么?

Prompt to display dialog for saving password to keychain from webview app

如何安装 @capgo/capacitor-autofill-save-password?

在项目目录运行 npm install @capgo/capacitor-autofill-save-password,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-autofill-save-password 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-autofill-save-password 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-autofill-save-password 可以商用吗?

@capgo/capacitor-autofill-save-password 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-autofill-save-password 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-autofill-save-password 在 2026/10/09 – 2026/11/07 这 30 天内被下载 75,478 次,日均约 2,516 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-autofill-save-password 还在维护吗?

最新版本 8.2.3 发布于 2026/10/19(20 天前);至今共发布 70 个版本,其中过去 12 个月发布了 51 个;首次发布于 2025/05/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。