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

# Lynx 3.7：桌面端、SVG、Skills 与 ReactLynx 更新

[← 所有文章](/next/zh/blog/)

2026年4月16日

![Wang Zhixuan](https://github.com/icecreamx10.png)Wang Zhixuan多平台主管 @ Lynx![夏梦非](https://github.com/MoonfaceX.png)夏梦非组件主管 @ Lynx![李一鸣](https://github.com/upupming.png)李一鸣工程师 @ Lynx![Lynx 团队](https://github.com/lynx-family.png)Lynx 团队lynxjs.org

Lynx 3.7 已经正式发布！

本次版本正式支持 **macOS** 和 **Windows** 桌面端平台，引入了新的 **SVG** 元件，引入了新的 **Agent Skills** 以提升可观测性，并为 **ReactLynx** 带来了更简单的 External Bundle presets 和跨线程共享模块能力。


## 桌面端支持：macOS 与 Windows

我们[此前计划](/next/zh/blog/lynx-open-source-roadmap-2025.md)在 Lynx 3.5 中开源桌面端支持，[随后决定](/next/zh/blog/lynx-3-5.md#桌面端支持预告)进一步开源完整的桌面端技术栈。在 Lynx 3.7 中，这一愿景已成为现实。

Lynx 正式支持 **macOS** 和 **Windows** 作为一级平台。你现在可以在原生桌面应用中构建和渲染 Lynx 视图，使用与移动端和 Web 端完全相同的前端技术栈和工具链。
我们也计划在最近开源 Lynxtron，它是一个 Electron-like 的桌面应用框架，使用 Lynx 作为 UI 渲染层。敬请期待！

**下面是一个示例: desktop**

**Entry:** `src/mouse-cursor`
**Bundle:** `dist/mouse-cursor.lynx.bundle` | Web: `dist/mouse-cursor.web.bundle`

```tsx
import { useResponsiveScale } from "../useResponsiveScale";
import desktopFrame from "./assets/desktop-frame.png";
import lynxLogo from "./assets/lynx-logo.png";
import { useDesktopDrag } from "./useDesktopDrag";
import "./App.css";

export function App() {
  const { handleLayoutChange, scale } = useResponsiveScale({
    baseWidth: 980,
    baseHeight: 420,
    minScale: 0.56,
  });
  const {
    desktopHot,
    docked,
    dragging,
    logoCardStyle,
    cancelDrag,
    finishDrag,
    handleDesktopLayout,
    handleLogoDown,
    handleMove,
    handleStageLayout,
  } = useDesktopDrag();
  const desktopFrameClassName = `DesktopFrame ${desktopHot ? "DesktopFrame--hot" : ""} ${
    docked ? "DesktopFrame--occupied" : ""
  }`;
  const logoCardClassName = `LogoCard ${dragging ? "LogoCard--dragging" : ""} ${docked ? "LogoCard--docked" : ""}`;
  const posterStyle = {
    gap: `${18 * scale}px`,
    paddingTop: `${28 * scale}px`,
    paddingBottom: `${24 * scale}px`,
  };
  const headerStyle = {
    gap: `${8 * scale}px`,
    maxWidth: `${760 * scale}px`,
  };
  const titleStyle = {
    fontSize: `${44 * scale}px`,
  };

  return (
    <page
      className="Page"
      bindmousemove={handleMove}
      bindmouseup={finishDrag}
      bindmouseleave={cancelDrag}
      bindlayoutchange={handleLayoutChange}
    >
      <view className="PageBackdrop">
        <view className="PageOrb" />
        <view className="BackdropGlow BackdropGlow--a" />
        <view className="BackdropGlow BackdropGlow--b" />
        <view className="BackdropGlow BackdropGlow--accent" />
      </view>
      <view className="Poster" style={posterStyle}>
        <view className="Header" style={headerStyle}>
          <text className="Title" style={titleStyle}>Bringing Lynx to desktop</text>
        </view>

        <view className="Stage" bindlayoutchange={handleStageLayout}>
          <view className={desktopFrameClassName} bindlayoutchange={handleDesktopLayout}>
            <image src={desktopFrame} className="DesktopFrameImage" />
          </view>

          <view
            className={logoCardClassName}
            style={logoCardStyle}
            bindmousedown={handleLogoDown}
            draggable={false}
          >
            <image src={lynxLogo} className="LogoImage" draggable={false} />
          </view>
        </view>
      </view>
    </page>
  );
}

```

v0.3.1



### CSS 与元件支持

渲染核心在各平台间复用（包括 CSS 引擎），**CSS 属性覆盖率**自然接近完整，目前达 **97%**（319 项中的 311 项）。桌面端界面由 [**Lynx 自绘渲染**](https://github.com/lynx-family/lynx/tree/develop/clay)，而不是通过系统原生控件拼装，原生元件需要基于自绘渲染器重新实现，**元素属性覆盖率**目前为 **73%**（246 项中的 179 项），macOS 与 Windows 的支持范围保持一致，并持续扩展中。已覆盖的 CSS 能力包括：

- **布局**：Flexbox、Grid、Linear Layout、完整盒模型、定位与相对定位。
- **样式**：排版、边框、阴影、渐变、蒙版、滤镜，以及 [CSS 自定义属性](/next/zh/api/css/properties/css-variable.md)。
- **动画**：`animation`、`transition`、`@keyframes` 和完整的 transform 能力。

这意味着大多数为移动端构建的 Lynx 页面已经可以在桌面端渲染，前端代码通常只需极少修改甚至无需修改。每个 API 页面上方均提供兼容性概览，下方附有详细的兼容性表格。也可在 [API 兼容状态看板](https://lynxjs.org/api/status) 上一览全局，现已包含 **macOS** 和 **Windows** 列。

### 桌面端专属能力

#### [鼠标事件](/next/zh/api/lynx-api/event/mouse-event.md)

```tsx
<view
  onMouseDown={(e) =>
    console.log(`按键 ${e.button} 位置 (${e.clientX}, ${e.clientY})`)
  }
  onMouseMove={(e) => handleHover(e)}
  onMouseLeave={() => resetState()}
/>
```

#### [键盘事件](/next/zh/api/lynx-api/event/key-event.md)

```tsx
<input
  onKeyDown={(e) => console.log(`按下按键: ${e.key}`)}
  onKeyUp={(e) => console.log(`释放按键: ${e.key}`)}
/>
```

#### [滚轮事件](/next/zh/api/lynx-api/event/wheel-event.md)

```tsx
<view onWheel={(e) => console.log(`滚轮偏移: ${e.deltaX}, ${e.deltaY}`)} />
```

#### [CSS `cursor`](/next/zh/api/css/properties/cursor.md) \{#css-cursor}

```tsx
<view style={{ cursor: 'pointer' }}>
  <text>Hover me</text>
</view>
```

### 快速上手

桌面端的接入细节可直接查看[将 Lynx 集成到现有应用](/next/zh/guide/start/integrate-with-existing-apps.md)。该页面现已包含与 Android、iOS、HarmonyOS、Web 并列的桌面端指南。
后续也会有一个由 Lynxtron 构建的 playground 应用，在桌面端更直接地获取并运行 Lynx 示例。

## `<svg>`：可缩放矢量图形

[`<svg>`](/next/zh/api/elements/built-in/svg.md) 作为独立元件在 Lynx 3.7 中新增，为图标、图表和其他分辨率无关的图形场景提供跨平台的原生矢量渲染能力。

`<svg>` 支持内联矢量内容：

**下面是一个示例: svg**

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

```tsx {35}
// Copyright 2024 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 } from "@lynx-js/react";

const logoContent = `<svg width="320" height="320" viewBox="0 0 320 320" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
  <linearGradient id="panelFill" x1="28" y1="28" x2="292" y2="292" gradientUnits="userSpaceOnUse">
    <stop offset="0%" stop-color="#26292D" stop-opacity="0.72"/>
    <stop offset="55%" stop-color="#4B4F56" stop-opacity="0.62"/>
    <stop offset="100%" stop-color="#8B9098" stop-opacity="0.52"/>
  </linearGradient>
</defs>
<rect x="28" y="28" width="264" height="264" rx="40" fill="url(#panelFill)"/>
<rect x="28.5" y="28.5" width="263" height="263" rx="39.5" stroke="#FFFFFF" stroke-opacity="0.08"/>
<g transform="translate(100 100) scale(6)" opacity="0.98">
  <path fill-rule="evenodd" clip-rule="evenodd" d="M5.19683 4.42475L2.58326 6.22507C2.29923 6.42072 2.10258 6.71472 2.0335 7.04698L1.77798 8.27604C1.76443 8.34121 1.73438 8.40204 1.69058 8.45301L0.504615 10.0077C0.344941 10.1935 0.348791 10.6871 0.786137 11.0031C0.953848 11.1493 1.17807 11.477 1.43312 11.8497L1.43312 11.8497C1.97313 12.639 2.65131 13.6302 3.22376 13.5272C4.03382 13.2426 5.02541 13.1516 5.78673 13.5272C7.2667 14.8049 6.90331 15.983 6.38234 17.672C6.17271 18.3516 5.93755 19.114 5.78673 19.9988C6.49755 17.4117 8.09592 14.4069 10.9781 13.3874C10.4588 12.9632 9.39906 12.5691 8.46129 12.4742C8.46129 12.4742 11.3423 10.0077 14.8957 8.87434C12.4151 2.97197 8.32052 0.151295 8.32052 0.151295C8.11187 -0.10677 7.69054 -0.0221092 7.6036 0.295351C7.53376 1.22845 7.41798 1.86295 7.22685 2.46105L5.78673 0.799291C5.6363 0.61794 5.33557 0.722655 5.33707 0.955861C5.5809 2.31136 5.54668 3.07222 5.19683 4.42475ZM6.21052 4.30085L6.21912 4.3003C6.23794 4.29909 6.25646 4.29664 6.27456 4.29302L6.21052 4.30085ZM8.15541 1.25793C9.1423 2.96321 9.58937 3.932 9.74102 5.73998C8.6912 5.14364 8.23382 4.99187 7.46183 4.99565C7.91215 3.62621 8.04976 2.8016 8.15541 1.25793Z" fill="white"/>
  <path d="M14.4988 13.9228C10.479 14.8427 8.19556 16.2278 6.44922 19.9994C9.58406 14.7399 19.0737 15.6805 19.0737 15.6805C18.8964 14.8214 17.0097 13.183 15.7688 12.1782C15.7688 12.1782 16.7699 10.9474 18.983 10.3244C18.983 10.3244 14.728 10.5709 12.2508 11.9084C13.0533 12.3319 14.0812 13.0467 14.4988 13.9228Z" fill="white"/>
</g>
</svg>`;

const App = () => {
  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "#0f0f10",
        padding: "32px",
      }}
    >
      <svg content={logoContent} style={{ width: "320px", height: "320px" }} />
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



也可以直接加载外部 SVG 资源：

```tsx
<svg
  style={{ width: '100px', height: '100px' }}
  src="https://example.com/icon.svg"
/>
```

为了最大化性能，`<svg>` 将解析工作交由后台独立线程处理，并将整个图形作为一个原生视图进行渲染，而非为每个节点创建独立的元素。这使得主线程在解析耗时和节点数量上都保持轻量，非常适合图标、插画和图表等静态展示场景。它支持 [17 个常用 SVG 标签和超过 40 个属性](/next/zh/api/elements/built-in/svg.md)，并在 Android、iOS、HarmonyOS、macOS、Windows 和 Web 之间保持一致的渲染表现。

## Agent Skills

作为 [Lynx for AI](/next/zh/ai/index.md) 的一部分，六个 [Agent Skills](https://github.com/lynx-community/skills) 现已开源。安装任意技能：

```bash
npx skills add lynx-community/skills -s <skill-name>
```

| 技能                            | 功能                                          |
| ----------------------------- | ------------------------------------------- |
| **reactlynx-best-practices**  | 静态分析、自动修复，以及编写双线程 ReactLynx 代码的最佳实践规则。      |
| **lynx-devtool**              | 通过命令行检查运行中 Lynx 应用的 DOM、控制台输出和运行时状态。        |
| **lynx-typescript**           | Lynx 项目中 TypeScript 环境配置、类型与事件处理的指导。        |
| **trace-analysis**            | 分析 `.ptrace` 文件，定位渲染瓶颈与性能回退。                |
| **trace-record**              | 采集 Lynx 性能 trace，支持系统 trace 和 JS profiling。 |
| **lynx-debug-info-remapping** | 将主线程压缩后的错误位置映射回原始源码。                        |

配合 [Lynx DevTool MCP](/next/zh/ai/lynx-devtool-mcp.md)，coding agent 现在可以检查运行中的页面、验证交互并缩短自调试链路。

## ReactLynx

### External Bundle Presets

[External Bundle](/next/zh/guide/build/external-bundle.md) 允许你构建一次 Lynx bundle，然后在多个 Lynx 应用中运行时加载。当你需要跨应用共享 ReactLynx 组件或通用业务 bundle 时，可以使用它。与 [Chunk Splitting](https://rsbuild.rs/zh/config/performance/chunk-split) 用于拆分单个应用内代码不同，External Bundle 专为跨应用复用而设计。

Lynx 3.7 通过 [`defineExternalBundleRslibConfig`](/next/zh/api/packages/lynx-bundle-rslib-config.md) 新增了内置 presets 以简化配置：

```ts
import { defineExternalBundleRslibConfig } from '@lynx-js/lynx-bundle-rslib-config';
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';

export default defineExternalBundleRslibConfig({
  id: 'comp-lib',
  source: {
    entry: {
      './App.js': './external-bundle/CompLib.tsx',
    },
  },
  plugins: [pluginReactLynx()],
  output: {
    externalsPresets: {
      reactlynx: true,
    },
  },
});
```

然后在宿主应用里加载这份 bundle：

**下面是一个示例: external-bundle**

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

```js
// Copyright 2024 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 { pluginExternalBundle } from "@lynx-js/external-bundle-rsbuild-plugin";
import { pluginQRCode } from "@lynx-js/qrcode-rsbuild-plugin";
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
import { pluginLynx } from "@lynx-js/rsbuild-plugin";
import { defineConfig } from "@rsbuild/core";
import pkg from "./package.json" with { type: "json" };

export default defineConfig({
  environments: {
    lynx: {},
  },
  source: {
    entry: {
      index: "./src/index",
    },
  },
  output: {
    assetPrefix: `https://unpkg.com/@lynx-example/external-bundle@${pkg.version}/dist`,
  },
  plugins: [
    pluginLynx({
      output: {
        filename: {
          bundle: "[name].[platform].bundle",
        },
      },
    }),
    pluginReactLynx(),
    pluginQRCode(),
    pluginExternalBundle({
      externalBundleRoot: "dist-external-bundle",
      externalsPresets: {
        reactlynx: true,
      },
      externals: {
        "lodash-es": {
          bundlePath: "lodash-es.lynx.bundle",
          background: { sectionPath: "lodash-es" },
          mainThread: { sectionPath: "lodash-es__main-thread" },
          async: false,
          timeout: 10000,
        },
        "./utils": {
          bundlePath: "utils.lynx.bundle",
          background: { sectionPath: "utils" },
          async: false,
          timeout: 10000,
        },
        "./components": {
          bundlePath: "comp.lynx.bundle",
          background: { sectionPath: "component" },
          mainThread: { sectionPath: "component__main-thread" },
          async: true,
          timeout: 5000,
        },
      },
      timeout: 10000,
    }),
  ],
});

```

v0.1.0



### 跨线程共享模块

默认情况下，主线程函数无法直接调用没有 [`'main thread'` 指令](/next/zh/react/main-thread-script.md)的普通函数，这使得代码复用变得困难。[共享模块](/next/zh/react/main-thread-script.md#跨线程共享模块)机制解决了这一限制，允许你显式声明某些模块可在主线程和后台线程之间共享。

在 import 语句后添加 `with { runtime: 'shared' }`，该模块导出的函数、类和对象即可在主线程函数中直接调用：

**下面是一个示例: main-thread**

**Entry:** `src/shared-module`
**Bundle:** `dist/shared-module.lynx.bundle` | Web: `dist/shared-module.web.bundle`

```tsx
import { runOnBackground, useMainThreadRef, useMemo, useState } from "@lynx-js/react";
import type { MainThread } from "@lynx-js/types";
import { getColorCount, getNextColor } from "./color-utils.js" with { runtime: "shared" };

export function App() {
  // --- Background Thread state ---
  const [count, setCount] = useState(0);
  const currentColor = useMemo(() => getNextColor(count), [count]);

  function incrementCount() {
    setCount((prev) => prev + 1);
  }

  // --- Main Thread function ---
  const boxRef = useMainThreadRef<MainThread.Element & { __colorIdx?: number }>(null);

  const onTap = () => {
    "main thread";
    // Use shared function directly on the Main Thread to get color
    const idx = boxRef.current?.__colorIdx ?? 0;
    const nextIdx = idx + 1;
    const color = getNextColor(nextIdx);

    boxRef.current?.setStyleProperty("background-color", color);
    if (boxRef.current) boxRef.current.__colorIdx = nextIdx;

    // Also update BG state so the text reflects the change
    runOnBackground(incrementCount)();
  };

  return (
    <view
      style={{
        width: "100%",
        height: "100%",
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        backgroundColor: "white",
      }}
    >
      <view
        main-thread:ref={boxRef}
        main-thread:bindtap={onTap}
        style={{
          width: "200px",
          height: "200px",
          backgroundColor: currentColor,
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
          borderRadius: "16px",
        }}
      >
        <text style={{ fontSize: "16px", color: "white", fontWeight: "bold" }}>
          Tap to cycle
        </text>
        <text style={{ fontSize: "14px", color: "white", marginTop: "8px" }}>
          Color {(count % getColorCount()) + 1}/{getColorCount()}
        </text>
      </view>
    </view>
  );
}

```

v0.5.0



## 升级指南

参照官网[接入 Lynx 到现有应用](https://lynxjs.org/3.7/zh/guide/start/integrate-with-existing-apps.html)，更新 Lynx 依赖版本，即可完成 Lynx 3.7 版本升级。
