Single code base to run Electron in desktop and web page

Hi there

Is it possible to have a single code base to run an Electron desktop app also on a web page?

If so please let me know how.



What you could do is a Node.js web app and just use electron as a container loading the url of the web app

I already have an electron app and need to migrate to web app but having a single code base for both desktop and web.


So recode your app in a node server app and use electron as a desktop wrapper :
Just load the url of the app :

browserWindow.loadURL("http://localhost:8080") // or whatever url is your app

And boom it works

The desktop app needs to work offline also. Pointing to URL won’t work.

I never said your URL was online. As an example I put a localhost address which means that the web app is launched on your computer.