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

# `<frame>`

APISummary
A page element similar to HTML's `<iframe>`, which can embed a Lynx page into the current page.

## Usage Guide

The following is an example of a main page loading an embedded page via the `<frame>` element.

- The main page passes `initData` and `globalProps` to the embedded page through the `data` and `global-props` attributes.
- The main page listens for the embedded page loading status via the `bindload` event, and can use `bindloadmetrics` to receive loading metrics.

### Main Page

**This is an example below: frame**

**Bundle:** `dist/frame.lynx.bundle`

```tsx {35-41}
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { type InitData, root, useState } from "@lynx-js/react";
import type { FrameLoadEvent, GlobalProps } from "@lynx-js/types";

const App = () => {
  const [bindLoadEvent, setBindLoadEvent] = useState({
    url: "",
    statusCode: 0,
    statusMessage: "",
  });
  const [initData, setInitData] = useState<InitData>({
    id: 123,
    name: "Alice",
    showDetail: true,
  });
  const [globalProps, setGlobalProps] = useState<GlobalProps>({
    message: "hello globalProps!",
    status: 42,
    loaded: true,
  });
  const handleLoad = (e: FrameLoadEvent) => {
    setBindLoadEvent(e.detail);
  };

  const frameUrl = `${process.env.ASSET_PREFIX}/in_frame.lynx.bundle`;
  return (
    <view>
      <text style={{ fontSize: "20px", color: "black", padding: "10px" }}>
        Below is the inline text example in frame page.
      </text>

      <frame
        style={{ width: "100%", height: "150px", border: "3px solid red" }}
        src={frameUrl}
        data={initData}
        bindload={handleLoad}
        global-props={globalProps}
      />
      <view
        style={{
          padding: "10px",
          width: "100%",
          height: "100px",
          border: "3px solid red",
        }}
        bindtap={() => setInitData({ ...initData, showDetail: !initData.showDetail })}
      >
        <text style={{ color: "black", fontSize: "20px" }}>
          {initData.showDetail ? "Hide Detail" : "Show Detail"}
        </text>
      </view>
      <text>load url: {bindLoadEvent.url}</text>
      <text>status code: {bindLoadEvent.statusCode}</text>
      <text>status message: {bindLoadEvent.statusMessage}</text>
    </view>
  );
};

root.render(<App />);

```

v0.2.0



### Embedded Page

**This is an example below: frame**

**Bundle:** `dist/frame.lynx.bundle`

```tsx
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useInitData } from "@lynx-js/react";

export function App() {
  const initData = useInitData();
  const globalProps = lynx.__globalProps;

  return (
    <view>
      <text style={{ fontSize: "30px", color: "orange" }}>I'm in frame!</text>
      <view style={{ border: "3px solid blue" }}>
        <text>{initData.id}</text>
        <text>{initData.name}</text>
        <text>{initData.showDetail ? "true" : "false"}</text>
        <text>{globalProps.message}</text>
        <text>{globalProps.status}</text>
        <text>{globalProps.loaded ? "true" : "false"}</text>
      </view>
    </view>
  );
}

root.render(<App />);

```

v0.2.0



:::tip
The `<frame>` element was introduced in 3.4. To use this element, the Lynx dependency version must be upgraded to 3.4 or higher.
:::

:::tip
Starting from 3.8, `auto-width` and `auto-height` can make `<frame>` follow the embedded page's content size. If automatic sizing is disabled, or if you are using an earlier version, you still need to manually set the frame width and height. Before the first content size is initialized, 3.9 and later can use `preset-width` and `preset-height` to set the preset size.
:::

## Attributes

### `auto-height`

Android
iOS
3.8

```tsx
// @defaultValue: false
'auto-height'?: boolean;
```

Lets the frame height follow the embedded Lynx page’s content height. When enabled, the embedded page can report its content size, and the frame uses that value as its measured height.

### `auto-width`

Android
iOS
3.8

```tsx
// @defaultValue: false
'auto-width'?: boolean;
```

Lets the frame width follow the embedded Lynx page’s content width. When enabled, the embedded page can report its content size, and the frame uses that value as its measured width.

### `data`

Android
iOS
3.4

```tsx
data?: Record<string, unknown>;
```

Passes data to the nested Lynx page within the frame.

### `enable-multi-async-thread`

Android
iOS
3.9

```tsx
// @defaultValue: false
'enable-multi-async-thread'?: boolean;
```

Overrides whether the embedded Lynx page uses multiple asynchronous threads. When omitted, the frame inherits the host setting.

### `global-props`

Android
iOS
3.6

```tsx
'global-props'?: Record<string, unknown>;
```

Passes
`globalProps`
to the Lynx page embedded in the frame. The embedded page can read it via
`lynx.__globalProps`
.

### `preset-height`

Android
iOS
3.9

```tsx
'preset-height'?: `${number}px` | `${number}rpx`;
```

Sets the preset height used before the embedded Lynx page receives an initialized content rect.

### `preset-width`

Android
iOS
3.9

```tsx
'preset-width'?: `${number}px` | `${number}rpx`;
```

Sets the preset width used before the embedded Lynx page receives an initialized content rect.

### `src`

Android
iOS
3.4

```tsx
src: string;
```

Sets the loading path for the frame resource.

## Events

Frontend can bind corresponding event callbacks to listen for runtime behaviors of the element, as shown below.

### `bindload`

Android
iOS
3.6

```tsx
bindload = (e: FrameLoadEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| statusCode | number | No | – | Android iOS 3.6 | 3.6 | Frame loaded status code. |
| statusMessage | string | No | – | Android iOS 3.6 | 3.6 | Frame loaded status message. |
| url | string | No | – | Android iOS 3.6 | 3.6 | The loaded url of the frame. |

Bind frame load event callback.

### `bindloadmetrics`

Android
iOS
3.9

```tsx
bindloadmetrics = (e: FrameLoadMetricsEvent) => {};
```

| Field | Type | Optional | Default | Platforms | Since | Description |
| --- | --- | --- | --- | --- | --- | --- |
| entry | FrameLoadMetricsEntry | No | – | Android iOS 3.9 | 3.9 | The raw `loadBundle` performance entry emitted by the embedded Lynx page. |
| mode | string | No | – | Android iOS 3.9 | 3.9 | The frame loading mode. |
| url | string | No | – | Android iOS 3.9 | 3.9 | The loaded url of the frame. |

Bind frame load metrics event callback.

## Compatibility

**Compatibility Table**

**Query:** `elements.frame`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/elements/frame.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| frame | Yes (3.4) | No | Yes (3.4) | No | No | Yes |
| src | Yes (3.4) | No | Yes (3.4) | No | No | Yes |
| data | Yes (3.4) | No | Yes (3.4) | No | No | Yes |
| global-props | Yes (3.6) | No | Yes (3.5) | No | No | Yes |
| auto-width | Yes (3.8) | No | Yes (3.8) | No | No | No |
| auto-height | Yes (3.8) | No | Yes (3.8) | No | No | Yes |
| preset-width | Yes (4.0) | No | Yes (3.7) | No | No | No |
| preset-height | Yes (4.0) | No | Yes (3.7) | No | No | No |
| enable-multi-async-thread | Yes (3.9) | No | Yes (3.9) | No | No | No |
| bindload | Yes (3.6) | No | Yes (3.5) | No | No | Yes |
| bindloadmetrics | Yes (3.9) | No | Yes (3.9) | No | No | No |
| boundingClientRect | Yes (3.4) | No | Yes (3.4) | No | No | Yes |
| requestAccessibilityFocus | Yes (3.4) | No | Yes (3.4) | No | No | No |
| scrollIntoView | Yes (3.4) | No | Yes (3.4) | No | No | Yes |
| setFocus | No | No | No | No | No | No |
| takeScreenshot | Yes (3.4) | No | Yes (3.4) | No | No | No |

**`frame`**

frame

**`boundingClientRect`**

<code>boundingClientRect</code>

**`requestAccessibilityFocus`**

<code>requestAccessibilityFocus</code>

**`scrollIntoView`**

<code>scrollIntoView</code>

**`setFocus`**

<code>setFocus</code>

**`takeScreenshot`**

<code>takeScreenshot</code>

