Question
Enable nodeIntegration or Use Preload Scripts: Which Safeguards the Renderer Process in NW.js?
Ari River
0 reputation · 15 Apr 2025, 22:13 UTC
122K views0
Goal
The aim is to protect the renderer from malicious or accidental access to the full Node.js runtime while still allowing developers to use native modules when needed.
Constraints & Uncertainty
- NW.js ≥0.54 disables
nodeIntegrationby default for security. - When
nodeIntegrationis disabled, developers can expose a limited API surface via apreloadscript andcontextBridge. - Documentation does not clearly state whether
contextIsolationis automatically enforced whennodeIntegrationis off; some builds still allow direct access to Node globals due to legacy flags. - There is no defined migration path for projects that rely on global Node APIs to the safer preload pattern.
Unresolved Decision
Which approach—enabling nodeIntegration for convenience or using a preload script for isolation—offers the best balance between security and developer ergonomics, and how does NW.js currently enforce contextIsolation when nodeIntegration is disabled?
Specific Questions
- Does NW.js enforce
contextIsolationwhennodeIntegrationis disabled, or can legacy flags still expose Node globals? - What migration steps are recommended for existing projects that rely on global Node APIs to move to a preload‑based API surface?