Application, BrowserWindow, and Webview.
1
Install WebviewJS
Add the package to your project:Make sure you have Node.js 24 or later and that your platform dependencies are satisfied. See the Installation guide for per-platform setup instructions.
2
Create your first window
Create a file called Run it:A native window opens and loads
app.mjs and add the following:app.mjs
https://example.com. Close the window to exit.Keep
BrowserWindow and Webview wrappers in variables for as long as you need to call their methods or use their event listeners. The application owns the native resources, so garbage-collecting a wrapper does not itself dispose the native object.3
Load local HTML
Instead of navigating to a URL, pass an Use the
html string to render content directly without a web server:html option for self-contained pages, prototypes, or any scenario where you want to serve content without a protocol handler or HTTP server.4
Handle window events
The The runtime shuts down automatically after the OS close request for the last tracked window. Calling
Application instance is a typed EventEmitter. Listen for lifecycle events to react to user actions:app.exit() in this handler is safe and idempotent, but it is not required to stop the pump.5
Add IPC — page to Node
The page can send messages to your Node.js code using Click the button in the window — “ping” appears in your terminal and the page updates to show “Node replied: pong”.
window.ipc.postMessage(). Listen with webview.onIpcMessage():Going further: expose async functions
For a cleaner request/response pattern, usewebview.expose() to publish an entire namespace of Node.js functions directly to the page. Every exposed function automatically becomes a Promise in the browser context:
SerializationError.
Event Loop
Understand how the non-blocking pump works and how to control it.
IPC Messaging
Deep-dive into page ↔ Node communication patterns.
API Reference — Application
Full reference for the Application class, events, and options.
Build Executables
Compile your app into a standalone executable.