Skills2026年5月9日·1 分钟阅读

NW.js — Build Desktop Apps with Web Technologies

NW.js lets you call Node.js modules directly from the DOM, enabling desktop application development using HTML, CSS, and JavaScript without a separate backend process.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
NW.js Desktop Apps
通用 CLI 安装命令
npx tokrepo install 34608aef-4b3c-11f1-9bc6-00163e2b0d79

Introduction

NW.js (formerly node-webkit) merges the Chromium rendering engine with Node.js into a single runtime. It allows developers to build cross-platform desktop applications using standard web technologies while having full access to the Node.js API from within the browser context.

What NW.js Does

  • Runs HTML/CSS/JS as native desktop applications on Windows, macOS, and Linux
  • Provides direct access to Node.js APIs from the DOM without IPC
  • Supports Chrome DevTools for debugging desktop apps
  • Enables packaging apps into standalone executables
  • Offers both normal and mixed-context modes for flexible architecture

Architecture Overview

NW.js integrates Chromium and Node.js at the event-loop level, sharing a single V8 instance. Unlike Electron which separates main and renderer processes, NW.js merges both contexts so that Node.js modules can be called directly from the DOM. The framework patches Chromium to inject Node.js bindings into each window context, giving web pages native capabilities without message passing.

Self-Hosting & Configuration

  • Install via npm (npm install nw) or download pre-built binaries from the releases page
  • Configure through package.json with fields like main, window, and node-remote
  • Set window.width, window.height, window.toolbar to control the app window
  • Use nw-builder or nw-packager to create distributable binaries for each platform
  • Enable node-remote to grant Node.js access to specific remote pages

Key Features

  • Single context: call require() and use fs, http, or any Node module directly in the browser
  • Chromium-based: supports modern web standards, WebGL, WebRTC, and CSS3
  • Source protection: compile JavaScript to V8 snapshots to protect intellectual property
  • Transparent windows, kiosk mode, and system tray support for native look and feel
  • Supports Chrome extensions and DevTools out of the box

Comparison with Similar Tools

  • Electron — separates main/renderer processes with IPC; NW.js merges them into one context
  • Tauri — uses the OS webview and Rust backend for smaller binaries; NW.js ships full Chromium
  • Neutralinojs — lightweight alternative with smaller footprint but fewer Node.js APIs
  • CEF (Chromium Embedded Framework) — C/C++ focused; NW.js targets JavaScript developers

FAQ

Q: How does NW.js differ from Electron? A: NW.js runs Node.js and Chromium in the same context, so you can call require() directly from a <script> tag. Electron uses separate processes that communicate via IPC.

Q: Can I protect my source code? A: Yes. NW.js supports compiling JavaScript files into V8 snapshots, which are not easily reverse-engineered.

Q: What platforms are supported? A: Windows (32/64-bit), macOS (x64/arm64), and Linux (32/64-bit).

Q: Is NW.js still actively maintained? A: Yes. It tracks upstream Chromium releases and publishes regular updates that follow the latest stable Chrome version.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产