@capgo/capacitor-webview-version-checker

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

Capacitor plugin for checking outdated Android WebView engines, emitting status events, and presenting native update prompts.

原始使用文档
文档目录19 节
  1. ➡️ Get started for free
  2. Key features
  3. Install
  4. Usage
  5. Why WebView Version Checker?
  6. Why we're doing this instead
  7. Android Provider Handling
  8. API
  9. check(...)
  10. startMonitoring(...)
  11. stopMonitoring()
  12. getLastStatus()
  13. showUpdatePrompt(...)
  14. openUpdatePage(...)
  15. addListener('statusChanged', ...)
  16. addListener('webViewLatest', ...)
  17. addListener('webViewOutdated', ...)
  18. Interfaces
  19. Type Aliases

@capgo/capacitor-webview-version-checker

Detect outdated WebView engines in your Capacitor app and prompt users to update, before old Android System WebView versions break your UI.

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-webview-version-checker in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-webview-version-checker to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-webview-version-checker for Capacitor apps

Key features

  • Check: check() returns whether the WebView is up to date, outdated or unknown.
  • Monitoring: startMonitoring() with statusChanged, webViewLatest and webViewOutdated events.
  • Update prompt: showUpdatePrompt() shows a native prompt, openUpdatePage() opens the right update page.
  • Policies: minimum version rules, with latestVersion for an explicit target.
  • Last status: getLastStatus() returns the latest result.
  • Platforms: iOS, Android and Web. Built for Android System WebView. On iOS the WebView follows the OS version and the prompt links to Apple's update help.

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-webview-version-checker` plugin in my project.

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

bun add @capgo/capacitor-webview-version-checker
bunx cap sync

Usage

Main use case: Browserslist-style compatibility checks by default.

The plugin uses this strategy out of the box, even if you do not add any plugin options:

  • minimumDeviceSharePercent defaults to 3
  • version-share data comes from a built-in dataset generated at build time from caniuse
  • no runtime version-share URL call is required for the default flow

Default setup (no plugin settings):

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    WebviewVersionChecker: {},
  },
};

export default config;

Simple config-only setup with native prompt:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    WebviewVersionChecker: {
      autoPromptOnOutdated: true,
      autoPromptDismissible: false,
    },
  },
};

export default config;

Advanced mode with custom threshold and custom dataset:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    WebviewVersionChecker: {
      autoCheckOnLoad: true,
      autoPromptOnOutdated: true,
      minimumDeviceSharePercent: 3,
      versionShareByMajor: {
        '137': 58.2,
        '136': 21.3,
        '135': 4.6,
        '134': 2.1,
      },
    },
  },
};

export default config;

What this means:

  • minimumDeviceSharePercent: 3 means "consider a version compatible only if that major version still represents at least 3% of devices in my dataset".
  • versionShareByMajor is your own dataset map where:
    • key = major version (for example 137)
    • value = share percent (0..100)
  • If you do not provide versionShareByMajor, the plugin uses its built-in generated dataset.

You can provide share data in two ways:

  • Inline with versionShareByMajor (as shown above)
  • Remote with versionShareApiUrl returning one of these shapes:
    • { "versionShareByMajor": { "137": 54.2, "136": 23.8 } }
    • { "shareByMajor": { "137": 54.2, "136": 23.8 } }
    • { "versions": [{ "major": 137, "share": 54.2 }, { "version": "136.0.0.0", "percent": 23.8 }] }

If you set versionShareApiUrl, the plugin fetches that URL at runtime and uses it as override.

Evaluation order:

  1. Browserslist-style threshold mode (minimumDeviceSharePercent + share dataset) is used first. By default this is 3% with the built-in generated dataset.
  2. Else the plugin compares against latestVersion / latestVersionApiUrl.
  3. Else it falls back to minimumMajorVersion.

Advanced usage with JavaScript (manual check, listeners, custom prompt):

import { WebviewVersionChecker } from '@capgo/capacitor-webview-version-checker';

const listener = await WebviewVersionChecker.addListener('webViewOutdated', (status) => {
  console.log('Outdated WebView detected', status);
});

const status = await WebviewVersionChecker.check({
  latestVersionApiUrl:
    'https://versionhistory.googleapis.com/v1/chrome/platforms/android/channels/stable/versions?page_size=1',
  minimumMajorVersion: 124,
  showPromptOnOutdated: true,
  autoPromptDismissible: false,
  promptTitle: 'Update WebView',
  promptMessage: 'Your WebView is outdated. Please update to continue safely.',
  promptUpdateButtonText: 'Update now',
  promptCancelButtonText: 'Later',
});

console.log('WebView status', status);

// later
listener.remove();

Why WebView Version Checker?

Capacitor already provides a built-in WebView minimum check through config:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  android: {
    minWebViewVersion: 124,
  },
  server: {
    errorPath: 'unsupported-webview.html',
  },
};

export default config;

Why we're doing this instead

  • android.minWebViewVersion is static config; it does not give runtime plugin events like webViewOutdated.
  • With server.errorPath, users are redirected to a static error page (hard block UX) instead of seeing a native modal in your normal app flow.
  • Without server.errorPath, Capacitor only logs the issue, but does not provide a native update prompt + store deep link UX.
  • This plugin gives soft enforcement: users can still open/use the app, get a native update modal, and you decide whether to require update later.
  • Main use case: this plugin brings Browserslist-style compatibility logic to Android WebView (for example, "support versions still used by at least 3% of devices"), while keeping your app usable.

Android Provider Handling

The plugin resolves the active WebView provider package and version, then routes update links to the correct package:

  • Android 5-6 and 10+: Android System WebView (com.google.android.webview)
  • Android 7-9: Google Chrome (com.android.chrome)

When provider detection is unavailable, fallback routing follows the same API-range rule above.

API

Public API for checking WebView freshness and guiding users to updates.

check(...)

check(options?: CheckWebViewOptions | undefined) => Promise<WebViewVersionStatus>

Runs a version check and returns the latest known status.

ParamType
optionsCheckWebViewOptions

Returns: Promise<WebViewVersionStatus>


startMonitoring(...)

startMonitoring(options?: StartMonitoringOptions | undefined) => Promise<MonitoringStateResult>

Enables background monitoring (typically on app resume).

ParamType
optionsStartMonitoringOptions

Returns: Promise<MonitoringStateResult>


stopMonitoring()

stopMonitoring() => Promise<MonitoringStateResult>

Disables monitoring.

Returns: Promise<MonitoringStateResult>


getLastStatus()

getLastStatus() => Promise<LastStatusResult>

Returns the last resolved status, or null if no check was run yet.

Returns: Promise<LastStatusResult>


showUpdatePrompt(...)

showUpdatePrompt(options?: ShowUpdatePromptOptions | undefined) => Promise<ShowUpdatePromptResult>

Shows a native prompt asking the user to update the WebView.

ParamType
optionsShowUpdatePromptOptions

Returns: Promise<ShowUpdatePromptResult>


openUpdatePage(...)

openUpdatePage(options?: OpenUpdatePageOptions | undefined) => Promise<OpenUpdatePageResult>

Opens the configured update page directly.

ParamType
optionsOpenUpdatePageOptions

Returns: Promise<OpenUpdatePageResult>


addListener('statusChanged', ...)

addListener(eventName: 'statusChanged', listenerFunc: (status: WebViewVersionStatus) => void) => Promise<PluginListenerHandle>

Fired for every successful status evaluation.

ParamType
eventName'statusChanged'
listenerFunc(status: WebViewVersionStatus) => void

Returns: Promise<PluginListenerHandle>


addListener('webViewLatest', ...)

addListener(eventName: 'webViewLatest', listenerFunc: (status: WebViewVersionStatus) => void) => Promise<PluginListenerHandle>

Fired when the state resolves to latest.

ParamType
eventName'webViewLatest'
listenerFunc(status: WebViewVersionStatus) => void

Returns: Promise<PluginListenerHandle>


addListener('webViewOutdated', ...)

addListener(eventName: 'webViewOutdated', listenerFunc: (status: WebViewVersionStatus) => void) => Promise<PluginListenerHandle>

Fired when the state resolves to outdated.

ParamType
eventName'webViewOutdated'
listenerFunc(status: WebViewVersionStatus) => void

Returns: Promise<PluginListenerHandle>


Interfaces

WebViewVersionStatus

Snapshot of the currently detected WebView status.

PropTypeDescription
platformWebViewPlatformNative platform that generated the status.
stateWebViewVersionStateResolved version state.
isLatestbooleanConvenience boolean equivalent to state === 'latest'.
checkedAtstringISO-8601 timestamp of the check.
reasonstringHuman-readable explanation for the reported state.
currentVersionstringCurrent WebView (or iOS system WebKit) version string.
currentMajorVersionnumberCurrent detected major version (if parseable).
latestVersionstringResolved latest version used for comparison.
latestMajorVersionnumberResolved latest major version (if parseable).
currentVersionSharePercentnumberDevice-share percentage for the installed WebView major version. Present only when a version-share dataset is available and includes the current major version.
minimumDeviceSharePercentnumberConfigured threshold used by compatibility-threshold mode. Present only when minimumDeviceSharePercent was requested for that check.
versionShareSourcestringSource used for version-share data. Values: - versionShareByMajor (inline dataset) - versionShareApiUrl (remote dataset) - generatedVersionShareByMajor (built-in dataset generated at build time)
deviceShareErrorstringDiagnostic message for compatibility-threshold mode. Present when minimumDeviceSharePercent was requested but the threshold check could not be fully evaluated.
providerPackagestringAndroid package name of the active WebView provider.
updateUrlstringURL that should be opened to update when outdated.
sourcestringInternal source identifier for the check implementation.

CheckWebViewOptions

Options for running a WebView version check.

PropTypeDescriptionDefault
showPromptOnOutdatedbooleanForce showing a native prompt if an outdated WebView is detected.false
sourcestringOptional tag included in the status payload so you can identify the check origin."manual"

MonitoringStateResult

Result payload for monitor controls.

PropTypeDescription
monitoringbooleanWhether monitoring is currently active.
checkOnResumebooleanWhether checks run on app resume while monitoring is active.
autoPromptOnOutdatedbooleanWhether outdated checks auto-trigger the native prompt.

StartMonitoringOptions

Options for starting monitor mode.

PropTypeDescriptionDefault
checkOnStartbooleanRun a check immediately when monitoring starts.true
checkOnResumebooleanWhether foreground checks should run while monitoring is enabled.true

LastStatusResult

Last known check snapshot.

PropTypeDescription
statusWebViewVersionStatus | nullNull until the first check completes.

ShowUpdatePromptResult

Result payload for showUpdatePrompt().

PropTypeDescription
shownbooleanWhether a native prompt was actually shown.
openedUpdatePagebooleanWhether the update page was opened from the prompt action.

ShowUpdatePromptOptions

Options for showing the native update prompt.

PropTypeDescription
titlestringPrompt title.
messagestringPrompt message.
updateButtonTextstringUpdate CTA label.
cancelButtonTextstringCancel CTA label.
updateUrlstringOptional URL to open if the update action is selected.

OpenUpdatePageResult

Result payload for openUpdatePage().

PropTypeDescription
openedbooleanWhether opening the update URL succeeded.
urlstringURL that was attempted.

OpenUpdatePageOptions

Options for opening the update page directly.

PropTypeDescription
updateUrlstringOptional URL override.

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

WebViewPlatform

'android' | 'ios' | 'web'

WebViewVersionState

'latest' | 'outdated' | 'unknown'

版本与发布记录

@capgo/capacitor-webview-version-checker 共发布 22 个版本,首次发布于 2026/02/19;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.2.19latest2026/10/1525 天前
8.2.182026/10/1327 天前
8.2.172026/10/091 个月前
8.2.162026/10/081 个月前
8.2.142026/10/081 个月前
8.2.152026/10/081 个月前

关于 @capgo/capacitor-webview-version-checker 的常见问题

@capgo/capacitor-webview-version-checker 是什么?

Capacitor plugin for checking outdated Android WebView engines, emitting status events, and presenting native update prompts.

如何安装 @capgo/capacitor-webview-version-checker?

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

@capgo/capacitor-webview-version-checker 支持 TypeScript 吗?

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

@capgo/capacitor-webview-version-checker 支持 ESM 还是 CommonJS?

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

@capgo/capacitor-webview-version-checker 可以商用吗?

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

@capgo/capacitor-webview-version-checker 的下载量有多少?

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

@capgo/capacitor-webview-version-checker 还在维护吗?

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