installationdownloadelectronzipdmg

What do I need to do/know to create an install button for an Electron application via a website?


I've been working with Electron for a few days now and before I decide if it's right for me, I want to know how to go about the installation/distribution process.

Basically, I'm creating an application and I want it to be a desktop application so it's easily accessible to the user. But I also want to have a website for installing the app as well as managing accounts/marketing etc, keeping all of that away from the user's experience when using the application.

The inspiration for that idea comes from Anki (https://apps.ankiweb.net). So I re-installed it just now to see how the process worked, and in one click it installs a .dmg file which in another click handles everything else. (On a Mac, at least?).

So how do I re-create something that works so smoothly, where in one click of a download button on a website it handles everything? I followed an electron-builder tutorial last night and noticed it creates .dmg and .zip files. Is it as simple as building the app, running the electron builder, creating a .dmg file, moving it into the application and adding the code to download it? I couldn't find much on this, so either it really is that simple or I'm missing something/not following the documentation Electron provides.

Also, is there any way to make it so that the same download button downloads the correct installer for the user's OS? I notice that Anki has multiple installers for Windows & Mac. No matter if this is necessary, I'm just curious as to the reason for this, & wondering if there's a better way.


Solution

  • You can use

    console.log(navigator.platform)
    

    to get the platform of the user. See: https://www.w3schools.com/jsref/prop_nav_platform.asp (Technical Details) for conversions. Sadly, I cannot help you with the rest of the website. There are some good Youtube tutorials that you can see that will really help!