For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/lynxtron/api/@lynx-js/cef-webview/index.md.
  • English
  • @lynx-js/cef-webview

    @lynx-js/cef-webview is the officially maintained Lynxtron native library that provides the CEF-backed <webview> element. It ships platform-specific Lynxtron native artifacts and a ./lynxtron entry that loads the current platform artifact so its static Lynx registrations run in the host process.

    Tooling Version

    For the matching AutoLink tooling and automatic packaging setup, see the webview setup guide.

    Install

    npm
    yarn
    pnpm
    bun
    deno
    npm install @lynx-js/cef-webview

    Host Entry

    Import the Lynxtron entry in the main process before creating a LynxWindow or loading a Lynx bundle:

    import { app } from '@lynx-js/lynxtron';
    import cefWebview from '@lynx-js/cef-webview/lynxtron';
    
    app.whenReady().then(() => {
      cefWebview.initialize();
      // Create LynxWindow instances after this call.
    });

    The initialize() method initializes Chromium Embedded Framework (CEF) for the current process. AutoLink also uses the ./lynxtron entry when staging the package for a Lynxtron host build.

    Initialization Result and Process Limit

    initialize(): boolean returns true on success and throws when native initialization fails. Do not continue creating WebViews after a failure; inspect the native logs for the cause.

    CEF selects its storage directory based on the host application's identity. Multiple instances sharing the same identity may encounter storage conflicts. One host can create multiple WebViews. A storage conflict is one possible initialization failure, not the only cause.

    The root and ./lynxtron exports include TypeScript declarations for this host API.

    Exports

    ExportDescription
    .CommonJS package entry.
    ./lynxtronLynxtron host entry that loads the current platform native binary.
    ./package.jsonPackage metadata.

    Package Metadata

    The package includes lynx.lib.json with Lynxtron metadata. The following excerpt abbreviates the complete platform matrix and Windows runtime file list:

    {
      "platforms": {
        "lynxtron": {
          "targets": [
            {
              "os": "darwin",
              "arch": "arm64",
              "files": ["dist/darwin/arm64/cef_extension.node"],
              "frameworks": [
                "dist/darwin/arm64/frameworks/Chromium Embedded Framework.framework"
              ],
              "appBundles": [
                "dist/darwin/arm64/frameworks/LynxtronWebview Helper.app",
                "dist/darwin/arm64/frameworks/LynxtronWebview Helper (Alerts).app",
                "dist/darwin/arm64/frameworks/LynxtronWebview Helper (GPU).app",
                "dist/darwin/arm64/frameworks/LynxtronWebview Helper (Plugin).app",
                "dist/darwin/arm64/frameworks/LynxtronWebview Helper (Renderer).app"
              ]
            },
            {
              "os": "win32",
              "arch": "x64",
              "files": [
                "dist/win32/x64/cef_extension.node",
                "dist/win32/x64/cef_subprocess.exe",
                "dist/win32/x64/libcef.dll",
                "dist/win32/x64/locales"
              ]
            }
          ]
        }
      }
    }

    files lists payloads that remain together in the installed package. frameworks and appBundles list macOS bundles that the builder places in Contents/Frameworks; nested applications are also included in the host's signing flow.

    For the end-to-end setup flow, see Using webview in Lynxtron.

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.