npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@capgo/capacitor-webview-guardian

v8.1.7

Published

Capacitor plugin to Detect when the WebView was killed in the background and relaunch it on foreground.

Readme

@capgo/capacitor-webview-guardian

Bring your Capacitor app back to life when the OS kills its WebView in the background: Webview Guardian checks the renderer on foreground and reloads it automatically.

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

Built and maintained with AI

We build, improve and fix our plugins with heavy use of AI, so issues usually get fixed in under a day and pull requests get feedback the same day. A human still reviews, tests and merges 50+ pull requests daily.

  • Most plugin issues get a fix pull request the same day, often within a couple of hours, and are usually resolved in one to two days.
  • Every pull request goes through our AI review system, usually within minutes.
  • Our AI pre-checks tests, code review, conventions and security, then a human reviews, tests and merges.
  • A human, Martin, reviews, tests and merges 50+ pull requests every day.
  • In the last 90 days, 95% of plugin issues were resolved.

Learn more about how we build with AI

Key features

  • Monitoring: startMonitoring() and stopMonitoring() watch foreground events.
  • Auto restart: reloads a terminated WebView with a reload, reloadFromOrigin or customUrl strategy.
  • Health probe: checkNow() tests the WebView right away.
  • State and events: getState() and the foreground event.
  • Platforms: iOS and Android. Not available on web.

Keep your Capacitor app alive after the OS kills its WebView while the app is in the background. Webview Guardian listens for foreground events, probes the renderer, and reloads it automatically (or notifies you so you can recover your own state) when the render process was terminated.

Compatibility

| Plugin version | Capacitor compatibility | Maintained | | -------------- | ----------------------- | ---------- | | 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-webview-guardian` 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-webview-guardian
npx cap sync

Usage

import { WebviewGuardian } from '@capgo/capacitor-webview-guardian';

await WebviewGuardian.startMonitoring({
  foregroundDebounceMs: 800,
  autoRestart: true,
  restartStrategy: 'reload',
});

WebviewGuardian.addListener('webviewRestarted', ({ reason }) => {
  console.info('[guardian] WebView restarted', reason);
});

API

startMonitoring(...)

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

Starts observing foreground events and automatically checks the WebView health.

| Param | Type | | ------------- | ------------------------------------------------------------------------- | | options | StartMonitoringOptions |

Returns: Promise<GuardianState>


stopMonitoring()

stopMonitoring() => Promise<GuardianState>

Stops any automatic foreground monitoring.

Returns: Promise<GuardianState>


getState()

getState() => Promise<GuardianState>

Returns the latest known monitoring state.

Returns: Promise<GuardianState>


checkNow(...)

checkNow(options?: CheckNowOptions | undefined) => Promise<CheckResult>

Forces a WebView health probe immediately.

| Param | Type | | ------------- | ----------------------------------------------------------- | | options | CheckNowOptions |

Returns: Promise<CheckResult>


addListener('foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted', ...)

addListener(eventName: 'foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted', listenerFunc: (event: GuardianEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------------- | | eventName | 'foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted' | | listenerFunc | (event: GuardianState) => void |

Returns: Promise<PluginListenerHandle>


Interfaces

GuardianState

| Prop | Type | | -------------------------- | -------------------- | | monitoring | boolean | | reason | string | | timestamp | string | | lastHealthyAt | string | | lastRestartAt | string | | lastCrashAt | string | | pendingRestartReason | string | | error | string |

StartMonitoringOptions

| Prop | Type | Description | | -------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | foregroundDebounceMs | number | Delay (in ms) before running a health check after the app re-enters the foreground. Defaults to 600ms to let the bridge finish resuming. | | pingScript | string | Script executed via evaluateJavascript/evaluateJavaScript to confirm the WebView is alive. Defaults to document.readyState. | | autoRestart | boolean | Automatically reloads the WebView when a terminated render process is detected. Disable to receive webviewCrashed events and restart manually. | | restartStrategy | RestartStrategy | Strategy used when restarting the WebView. Defaults to reload. | | customRestartUrl | string | Custom HTTPS/HTTP URL to load when restartStrategy is customUrl. | | debug | boolean | Emits verbose logging in the native layer when true. | | runInitialCheck | boolean | Whether an immediate health check should be executed right after enabling monitoring. Defaults to true. |

CheckResult

| Prop | Type | | -------------------- | -------------------- | | healthy | boolean | | restarted | boolean | | reason | string | | timestamp | string | | error | string | | pendingRestart | boolean |

CheckNowOptions

| Prop | Type | Description | | ------------ | ------------------- | ---------------------------------------------------------- | | reason | string | Text tag describing why a manual check is being requested. |

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

Type Aliases

RestartStrategy

'reload' | 'reloadFromOrigin' | 'customUrl'

GuardianEvent

GuardianState