Grim Reaper
Grim Reaper

Reputation: 561

Properly using Electron

I want to get into Electron, and I have already started learning about it, however I don't think I quite understand how I am supposed to use it. From what I gathered, with Electron I am able to create cross-desktop applications (Chromium) with HTML, CSS and Javascript and do tasks in the background (NodeJS).

What confuses me is the following:

For example, I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system (with MongoDB). It has HTML files for logging in and registering.

I am not sure how to use this with my Electron app, as the matter of fact, I don't quite understand how to actually use Electron. Should I move all of my login/register application code to the Electron application, or should I use Electron to somehow connect to my login/registration application and load the websites?

Upvotes: 5

Views: 2426

Answers (3)

certainly the best Tutorial I've seen for electronjs is The Electron API Demos app which is the official tutorial from electron and completely FREE :)

just download the main tutorial application which is named "ElectronAPIDemosSetup.exe" from GitHub (of course you can download "Electron API Demos-win32-ia32" and "electron-api-demos-2.0.2" to view and play with source codes) then run it and enjoy...

just as an additional hint I attached a screenshot from application here:

enter image description here

Upvotes: 0

Vishal Goyal
Vishal Goyal

Reputation: 55

You can simply start your Electron Journey with Basic app which allows you to play with it.

Best part about electron is - You can run it anywhere (Mac, Windows & Linux)

Do a checkout

git clone https://github.com/geek4teck/electron-quick-start

Change your Current Working Directory to electron-quick-start

cd electron-quick-start

You can then run

npm install

(Make sure nodejs is installed)

You can then run

npm start

which should start a basic browserwindow and should show your current node, npm version etc.

Hope this helps

Upvotes: 0

Denis Tsoi
Denis Tsoi

Reputation: 10404

How am I supposed to use this with my server?

You need to think about separating the application as a stand-alone desktop app (that acts as a client-side application) vs the server for your API and backend logic which are hosted by a cloud provider.

By doing this, you can focus on the separation of concerns for the desktop (electron) application as well as ensuring servers (such as API, authentication, and other backend logic) are well optimised and serving as multiple workers of themselves.

If I were to move my code to my Electron app, would it cause security issues?

There are some security concerns with an Electron application development if you do not regularly update your Node version (such as memory buffer overflow attacks).

Another issue to consider is how the Electron community serves and resolves issues of permissions for the client-side app and the regular file permissions which are granted when the user installs your app.

As a developer, the onus is on you to ensure third-party libraries are not damaging the user's computer. (imagine installing a library dependency whose purpose is to maliciously delete the entire file system).

I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system

For authentication, you can serve responses from your API based on the client-side requests/Posts that you provide to the authentication service. You don't necessarily have to provide/install the authentication server into your Electron app, as this can be somewhat troublesome for the user to update, as well as it exposes your authentication service for others to reverse-engineer/crack.

Upvotes: 5

Related Questions