# cap-webview-plugin

> This is capacitor plugin that how a website in a webview.

Latest version **1.0.3** (published 2024-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install cap-webview-plugin
pnpm add cap-webview-plugin
yarn add cap-webview-plugin
bun add cap-webview-plugin
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2024-04-03 |
| First published | 2024-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dylan COSTA |
| Maintainers | dylancostaletd |
| Keywords | capacitor, plugin, native |

## Links

- npm: https://www.npmjs.com/package/cap-webview-plugin
- Repository: https://github.com/Loiselet-Daigremont/cap-webview-plugin
- Homepage: https://github.com/Loiselet-Daigremont/cap-webview-plugin#readme
- Issues: https://github.com/Loiselet-Daigremont/cap-webview-plugin.git/issues
- npm.io page: https://npm.io/package/cap-webview-plugin

## Recent versions

- 1.0.3 (latest) — 2024-04-03
- 1.0.2 — 2024-04-02
- 1.0.1 — 2024-04-02
- 1.0.0 — 2024-04-02

## README

# webview-plugin

The "Webview Plugin" for Capacitor seamlessly integrates web content within your native application, offering a bridge to display websites directly in a WebView. This plugin is a versatile solution for developers looking to enhance their app with web-based functionalities or content. It's perfect for displaying entire websites, web-based interfaces, or HTML content without leaving the app environment. The plugin supports a range of customization options to ensure the web content fits naturally within your app, providing a cohesive user experience. Whether you're building an application that leverages online resources, or simply need to show web content as part of your app's functionality, the Webview Plugin makes it straightforward and efficient.

## Install

```bash
npm install webview-plugin
npx cap sync
```

## API

<docgen-index>

* [`showWebView(...)`](#showwebview)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### showWebView(...)

```typescript
showWebView(options: { url: string; }) => Promise<void>
```

| Param         | Type                          |
| ------------- | ----------------------------- |
| **`options`** | <code>{ url: string; }</code> |

--------------------

</docgen-api>


## Examples

### Angular

To use the "Webview Plugin" within an Angular application, follow this example which demonstrates how to integrate the plugin into a component. The example below illustrates how to display a WebView with a specific URL upon the component's initialization.

```typescript
// Import necessary modules
import { Component, OnInit } from '@angular/core';
// Ensure to adjust the import path based on your plugin's location
import { CapWebviewPlugin } from 'webview-plugin';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {

  // Component initialization method
  ngOnInit() {
    this.showWebView();
  }

  // Method to display the WebView
  async showWebView() {
    try {
      await CapWebviewPlugin.showWebView({ url: 'https://www.example.com' });
    } catch (error) {
      console.error('Error loading WebView', error);
    }
  }
}

### Typescript
For a simple TypeScript example without a specific framework like Angular, you can utilize the plugin as follows:

import { CapWebviewPlugin } from 'path-to-your-plugin/webview-plugin';

// Async function to demonstrate plugin usage
async function loadWebView() {
  try {
    await CapWebviewPlugin.showWebView({ url: 'https://www.example.com' });
  } catch (error) {
    console.error('Error loading WebView', error);
  }
}

---
_Source: https://npm.io/package/cap-webview-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
