Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason to use web server (Express) within Electron app?

I'm learning Electron and everything I'm seeing is using the file:// protocol to load pages, and so far this is working fine. I also see some references to using Express within Electron.

My question is - is there any reason to use a web server such as Express within an Electron app? What does it get you?

Thanks.

like image 620
TimTheEnchanter Avatar asked Oct 18 '22 19:10

TimTheEnchanter


1 Answers

I think the scenario is pretty odd: The combination of a desktop-UI with a server-framework seems to be somewhat counter-intuitive.

What you see when file:// is referenced are (local) file system calls - these could well be calls to other protocols like http:// or ws:// instead, and do not require the Express framework to be present.

Instead, Express enables your application to receive connections from the outside and act as a server. This could be a webserver serving static or dynamic content, a REST-API endpoint or some other kind of web service endpoint.

There is indeed a project showing exactly this combination: The Express server is responsible for serving content, Electron is used to wrap a logging-UI that displays whatever is currently happening.

From an architecturial standpoint however, I would probably seperate each of these concerns into seperate standalone applications.

like image 77
Jens Habegger Avatar answered Oct 29 '22 20:10

Jens Habegger