> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# `<webview>`

Shows a website or an HTML string inside your app, like an `<iframe>`. Use it for help pages, terms of service or sign-in pages. To embed another Lynx bundle, use [`<frame>`](/api/elements/frame.md).


## Usage

```typescript title="src/app/help.ts"
import { Component, signal } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-help',
  imports: [LYNX_ELEMENTS],
  template: `
    @if (loading()) {
      <text>Loading…</text>
    }
    <webview
      src="https://angular.dev"
      style="width: 100%; height: 400px;"
      (bindload)="loading.set(false)"
    ></webview>
  `,
})
export class Help {
  readonly loading = signal(true);
}
```

Import `LYNX_ELEMENTS` in your component (see [Elements](/api/angular-lynx/elements/index.md)).

:::warning
Needs [XElement](/guide/glossary.md#xelement) in custom native apps (see [Embedding](/guide/embedding/index.md)).
:::

## Attributes

**Clay** is a separate Lynx renderer used by Lynx's desktop apps. AngularLynx's iOS, Android and web builds don't use it, so you can ignore the Clay-only rows.

| Attribute           | Type       | Default     | Description                                                                                                                     |
| ------------------- | ---------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `src`               | `string`   | —           | URL to load. Changing it reloads the page. The web preview has limits: see [`src` in the web preview](#src-in-the-web-preview). |
| `html`              | `string`   | —           | HTML to load. Ignored when `src` is set.                                                                                        |
| `bounces`           | `boolean`  | `false`     | iOS only. Bounce at the edges.                                                                                                  |
| `scroll-bar-enable` | `boolean`  | `false`     | iOS only. Shows the scroll bar.                                                                                                 |
| `enable-debug`      | `boolean`  | `false`     | Lets you inspect the page with Chrome DevTools (Android) or Safari Web Inspector (iOS).                                         |
| `webview-type`      | `string`   | `'default'` | iOS and Android. Picks a custom web view that the [host app](/guide/glossary.md#host-app) provides.                             |
| `params`            | `object`   | —           | iOS and Android. Options for that custom web view.                                                                              |
| `initjs`            | `string`   | —           | Desktop (Clay) only. Script to run when the document is ready.                                                                  |
| `cookies`           | `object[]` | —           | Clay only. Cookies to set before loading, each `{ name, value, domain?, path?, secure?, httpOnly?, sameSite }`.                 |
| `use-osr`           | `boolean`  | `false`     | Clay only. Renders the page off screen.                                                                                         |

Plus the [common attributes](/api/elements/view.md#attributes), such as `id`, `class` and `style`.

### `src` in the web preview

In the [web preview](/guide/glossary.md#web-preview):

- **Chrome and Edge** load it without the cookies the site has in the browser.
- **Firefox and Safari** show a blocked page, while `bindload` still fires. Check URLs in Chrome or on a device, and use `html` in those browsers.

## Events

Read the payload from `$event.detail`. Angular types `$event` for each event: see [Element events](/api/angular-lynx/element-events.md#other-elements).

| Event                | `detail`                                  | Description                                 |
| -------------------- | ----------------------------------------- | ------------------------------------------- |
| `bindload`           | —                                         | The page finished loading.                  |
| `binderror`          | `{ errorCode: number; errorMsg: string }` | The page failed to load.                    |
| `bindmessage`        | `{ msg: string }`                         | The page sent a message to your app.        |
| `bindopenwindow`     | `{ url: string }`                         | Clay only. The page tried to open a window. |
| `bindlocationchange` | `{ url: string }`                         | Clay only. The page navigated to `url`.     |

Plus the [common events](/api/elements/view.md#events), such as `bindtap`.

## Methods

These **UI methods** ([Glossary](/guide/glossary.md#ui-method)) control the page. Call them with `invoke()` on the element (see [Call element methods](/guide/selector-query.md)).

| Method                                                               | Parameters         | Description                                                     |
| -------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------- |
| `reload`                                                             | —                  | Reloads the page.                                               |
| `eval`                                                               | `{ func: string }` | Calls a JavaScript function in the page, e.g. `'greet("Ada")'`. |
| `cookies.get`, `cookies.set`, `cookies.remove`, `cookies.flushStore` | Varies             | Clay only. Read and change the web view's cookies.              |

```typescript
import { Component, ElementRef, viewChild } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-help-page',
  imports: [LYNX_ELEMENTS],
  template: `
    <webview
      #help
      src="https://angular.dev"
      style="width: 100%; height: 400px;"
    ></webview>
    <view (bindtap)="reload()"><text>Reload</text></view>
  `,
})
export class HelpPage {
  readonly help = viewChild.required('help', { read: ElementRef });

  reload(): void {
    this.help().nativeElement.invoke?.('reload');
  }
}
```

## Related

- [`<frame>`](/api/elements/frame.md): embed another Lynx bundle
- [`<cover-view>`](/api/elements/cover-view.md): draw Lynx content above a web view on desktop
- [Call element methods](/guide/selector-query.md)
