Generating electron app from external website


#1

I am asking this question here since I could not find a solution anywhere on the internet.

I am working on an application which is very, very large. One of the key concepts of this large app is that each user can configure which functions they will use and which functions they do not use. This means that the application is different for each user. It would be useless to ship all of these functions in one electron installation, (since it would be enormous, and some users only need a small amount of features)

Because of this it seems attractive to me to build an electron app which is capable of loading a website, or parts of a website and then giving native support for it. Is it possible with Electron to load an external website, and to give that website then acces to the native capabilities of Electron? Can i acces i.e. the electron object from it? How would this be accomplished? I am aware of the security vulnerabilities.

I have looked into loadURL(‘link-to-website’); and there acces electron, but i am not able to exectute ‘require(‘electron’)’.

I hope I explained this problem clearly, and if something is unclear, or if I am completely missing a point somewhere, feel free to ask.

Looking forward for your response,
Lukas


#2

The unclear thing to me is why you’re looking for a more complicated solution. Downloadable plugins and components are a tried-and-true way of reducing the minimum size of a program, and with how Electron works, you don’t need to do much to support them, just load and run that additional JS code.


#3

The content/features of the app may change daily, and it would be a problem if I let the users update their app everyday. So I am trying to figure out if it is possible that the electron app can function as a normal website, but with native support. So the app can change without installing a specific update. Is that possible? How could this be achieved?

I hope this explains it more clearly.


#4

Electron is essentially a web browser (and multiple browsers have been built on it), so yes, I’m pretty sure it would work like that. To test it, you’d just have to write a small web app on your remote site that require()s something from Node, then have Electron access that app. In fact, that’s the reason why the docs strongly suggest not displaying arbitrary web sites within Electron, because a script that targets Node can easily drop malicious code on your hard drive.

Of course, make sure you read that page before you continue. Installing anything on your computer is a trust exercise, but you’re asking your users to trust you long-term, without even the chance to look at changelists and make updates themselves (which offers false security and most people don’t care, but I think it’s kind of nice to have).


#5

While Electron is built on top of some components of Chromium, specifically the rendering engine, it isn’t designed to be a web browser. I generally don’t recommend trying to turn Electron into what I call “a browser that only goes to one website”. Electron is more optimized for the single-page application style of building web apps … this can create challenges when trying to convert a multi-page web application for use in Electron.

With that said, some people have reported success in doing it. I just wouldn’t expect it to be without some land mines to navigate here and there.