{"id":42102166,"url":"https://github.com/Cap-go/capacitor-webview-guardian","last_synced_at":"2026-02-05T13:00:58.045Z","repository":{"id":323410646,"uuid":"1093133732","full_name":"Cap-go/capacitor-webview-guardian","owner":"Cap-go","description":"Capacitor plugin to Detect when the WebView was killed in the background and relaunch it on foreground.","archived":false,"fork":false,"pushed_at":"2026-01-26T11:37:14.000Z","size":579,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-26T21:37:40.979Z","etag":null,"topics":["capacitor","capacitor-plugin"],"latest_commit_sha":null,"homepage":"https://capgo.app","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-11-10T00:25:20.000Z","updated_at":"2026-01-26T11:37:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Cap-go/capacitor-webview-guardian","commit_stats":null,"previous_names":["cap-go/capacitor-webview-guardian"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-webview-guardian","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-webview-guardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-webview-guardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-webview-guardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-webview-guardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-webview-guardian/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-webview-guardian/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28963276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T00:42:38.011Z","status":"ssl_error","status_checked_at":"2026-02-01T00:42:35.920Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capacitor","capacitor-plugin"],"created_at":"2026-01-26T13:00:21.333Z","updated_at":"2026-02-05T13:00:58.039Z","avatar_url":"https://github.com/Cap-go.png","language":"Swift","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":["Capgo Capacitor Plugins","[Capgo plugins](https://capgo.app/)"],"sub_categories":["Utilities"],"readme":"# @capgo/capacitor-webview-guardian\n \u003ca href=\"https://capgo.app/\"\u003e\u003cimg src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/\u003e\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/?ref=plugin_webview_guardian\"\u003e ➡️ Get Instant updates for your App with Capgo\u003c/a\u003e\u003c/h2\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/consulting/?ref=plugin_webview_guardian\"\u003e Missing a feature? We’ll build the plugin for you 💪\u003c/a\u003e\u003c/h2\u003e\n\u003c/div\u003e\n\nKeep 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.\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **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.\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-webview-guardian\nnpx cap sync\n```\n\n## Usage\n\n```ts\nimport { WebviewGuardian } from '@capgo/capacitor-webview-guardian';\n\nawait WebviewGuardian.startMonitoring({\n  foregroundDebounceMs: 800,\n  autoRestart: true,\n  restartStrategy: 'reload',\n});\n\nWebviewGuardian.addListener('webviewRestarted', ({ reason }) =\u003e {\n  console.info('[guardian] WebView restarted', reason);\n});\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`startMonitoring(...)`](#startmonitoring)\n* [`stopMonitoring()`](#stopmonitoring)\n* [`getState()`](#getstate)\n* [`checkNow(...)`](#checknow)\n* [`addListener('foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted', ...)`](#addlistenerforeground--webviewhealthy--webviewcrashed--webviewrestarted-)\n* [Interfaces](#interfaces)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### startMonitoring(...)\n\n```typescript\nstartMonitoring(options?: StartMonitoringOptions | undefined) =\u003e Promise\u003cGuardianState\u003e\n```\n\nStarts observing foreground events and automatically checks the WebView health.\n\n| Param         | Type                                                                      |\n| ------------- | ------------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#startmonitoringoptions\"\u003eStartMonitoringOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#guardianstate\"\u003eGuardianState\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### stopMonitoring()\n\n```typescript\nstopMonitoring() =\u003e Promise\u003cGuardianState\u003e\n```\n\nStops any automatic foreground monitoring.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#guardianstate\"\u003eGuardianState\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### getState()\n\n```typescript\ngetState() =\u003e Promise\u003cGuardianState\u003e\n```\n\nReturns the latest known monitoring state.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#guardianstate\"\u003eGuardianState\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### checkNow(...)\n\n```typescript\ncheckNow(options?: CheckNowOptions | undefined) =\u003e Promise\u003cCheckResult\u003e\n```\n\nForces a WebView health probe immediately.\n\n| Param         | Type                                                        |\n| ------------- | ----------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#checknowoptions\"\u003eCheckNowOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#checkresult\"\u003eCheckResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### addListener('foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted', ...)\n\n```typescript\naddListener(eventName: 'foreground' | 'webviewHealthy' | 'webviewCrashed' | 'webviewRestarted', listenerFunc: (event: GuardianEvent) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\n| Param              | Type                                                                                    |\n| ------------------ | --------------------------------------------------------------------------------------- |\n| **`eventName`**    | \u003ccode\u003e'foreground' \\| 'webviewHealthy' \\| 'webviewCrashed' \\| 'webviewRestarted'\u003c/code\u003e |\n| **`listenerFunc`** | \u003ccode\u003e(event: \u003ca href=\"#guardianstate\"\u003eGuardianState\u003c/a\u003e) =\u0026gt; void\u003c/code\u003e             |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### Interfaces\n\n\n#### GuardianState\n\n| Prop                       | Type                 |\n| -------------------------- | -------------------- |\n| **`monitoring`**           | \u003ccode\u003eboolean\u003c/code\u003e |\n| **`reason`**               | \u003ccode\u003estring\u003c/code\u003e  |\n| **`timestamp`**            | \u003ccode\u003estring\u003c/code\u003e  |\n| **`lastHealthyAt`**        | \u003ccode\u003estring\u003c/code\u003e  |\n| **`lastRestartAt`**        | \u003ccode\u003estring\u003c/code\u003e  |\n| **`lastCrashAt`**          | \u003ccode\u003estring\u003c/code\u003e  |\n| **`pendingRestartReason`** | \u003ccode\u003estring\u003c/code\u003e  |\n| **`error`**                | \u003ccode\u003estring\u003c/code\u003e  |\n\n\n#### StartMonitoringOptions\n\n| Prop                       | Type                                                        | Description                                                                                                                                      |\n| -------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |\n| **`foregroundDebounceMs`** | \u003ccode\u003enumber\u003c/code\u003e                                         | Delay (in ms) before running a health check after the app re-enters the foreground. Defaults to 600ms to let the bridge finish resuming.         |\n| **`pingScript`**           | \u003ccode\u003estring\u003c/code\u003e                                         | Script executed via `evaluateJavascript`/`evaluateJavaScript` to confirm the WebView is alive. Defaults to `document.readyState`.                |\n| **`autoRestart`**          | \u003ccode\u003eboolean\u003c/code\u003e                                        | Automatically reloads the WebView when a terminated render process is detected. Disable to receive `webviewCrashed` events and restart manually. |\n| **`restartStrategy`**      | \u003ccode\u003e\u003ca href=\"#restartstrategy\"\u003eRestartStrategy\u003c/a\u003e\u003c/code\u003e | Strategy used when restarting the WebView. Defaults to `reload`.                                                                                 |\n| **`customRestartUrl`**     | \u003ccode\u003estring\u003c/code\u003e                                         | Custom HTTPS/HTTP URL to load when `restartStrategy` is `customUrl`.                                                                             |\n| **`debug`**                | \u003ccode\u003eboolean\u003c/code\u003e                                        | Emits verbose logging in the native layer when true.                                                                                             |\n| **`runInitialCheck`**      | \u003ccode\u003eboolean\u003c/code\u003e                                        | Whether an immediate health check should be executed right after enabling monitoring. Defaults to `true`.                                        |\n\n\n#### CheckResult\n\n| Prop                 | Type                 |\n| -------------------- | -------------------- |\n| **`healthy`**        | \u003ccode\u003eboolean\u003c/code\u003e |\n| **`restarted`**      | \u003ccode\u003eboolean\u003c/code\u003e |\n| **`reason`**         | \u003ccode\u003estring\u003c/code\u003e  |\n| **`timestamp`**      | \u003ccode\u003estring\u003c/code\u003e  |\n| **`error`**          | \u003ccode\u003estring\u003c/code\u003e  |\n| **`pendingRestart`** | \u003ccode\u003eboolean\u003c/code\u003e |\n\n\n#### CheckNowOptions\n\n| Prop         | Type                | Description                                                |\n| ------------ | ------------------- | ---------------------------------------------------------- |\n| **`reason`** | \u003ccode\u003estring\u003c/code\u003e | Text tag describing why a manual check is being requested. |\n\n\n#### PluginListenerHandle\n\n| Prop         | Type                                      |\n| ------------ | ----------------------------------------- |\n| **`remove`** | \u003ccode\u003e() =\u0026gt; Promise\u0026lt;void\u0026gt;\u003c/code\u003e |\n\n\n### Type Aliases\n\n\n#### RestartStrategy\n\n\u003ccode\u003e'reload' | 'reloadFromOrigin' | 'customUrl'\u003c/code\u003e\n\n\n#### GuardianEvent\n\n\u003ccode\u003e\u003ca href=\"#guardianstate\"\u003eGuardianState\u003c/a\u003e\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-webview-guardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCap-go%2Fcapacitor-webview-guardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-webview-guardian/lists"}