Can electronjs be used for websites

Viewed 5532

I'm offered to build a project, a web application, or basically a website. But the client prefers that I use electronjs to develop it.

But as far as I know (Correct me if I'm wrong), electronjs is for building cross-platform desktop applications ONLY which can run on any OS like Windows, Linus, Mac, etc but not on a browser via URL. Since it uses HTML, CS, JS, or basically the browser's language, it may have confused my client to think that it can be used also for building web applications.

So my questions are:

  • Can I use electronjs for building a web application?
  • If yes, is it wise to use? Or building it in reactjs is better?
4 Answers

You are right. Electron was developed for building standalone desktop applications. It bundles a node.js server with a chromium browser to give the feeling of an application but of course uses web technology.

That said you can of course do a lot of things electron can by using a node.js server. But a lot of things - especially clientside file manipulation, or playing around with windows is than limited.

On the other hand you can build an electron application that accesses an online Server to retreive data or display webpages.

I would say no. Electron is used to build cross-platform desktop apps, and is not generally used to build websites. You could probably do it, but this is limited to very special circumstances, I would advise against it. You're probably better off using a framework meant to develop Single Web Apps, like React or Vue.

Like @Torf said with electron it's possible to have a nodejs application run in it's own chrome browser window (which looks like it's own application). But it's just a "website" which is displayed. So you can code a simple site and use it as website, windows application etc. it looks the same on all platforms.

What the hell then code-server does? https://github.com/cdr/code-server

The fact that it is not yet generically implemented, does not mean "no". Code-server is literally example of electron app that can be run inside a docker container, but have it's gui - as it is - rendered in a webpage.

Yes, not yet generically done, but is exactly possible.

Related