Enabling integration with Node in Electron.js

Node's integration with Electron refers to the ability to access Node.js resources from within the rendering process; with this, we can make use of the Electron API from the website in an easy and direct way.

The integration with Node is disabled by default in Electron and for final or production applications it is recommended to disable it as a security measure.

Being able to use Node from the web page (and with this, being able to import and use any package), is essential to carry out various operations that, in summary, such as communication between processes that we will see in the next section; To enable the integration with Node, we put:

index.js

let win = new BrowserWindow({
   width: 800,
   height:600,
   webPreferences:{
       nodeIntegration: true,
       contextIsolation: false 
   }
})

Remember that the previous material is part of mi curso para iniciales sobre Electron.js

- Andrés Cruz

En español
Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.