Book Image

Building Cross-Platform Desktop Applications with Electron

By : Muhammed Jasim
Book Image

Building Cross-Platform Desktop Applications with Electron

By: Muhammed Jasim

Overview of this book

<p>Though web applications are becoming increasingly popular, desktop apps are still important. The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML, and CSS, and this book will teach you how to create your first desktop application with Electron. It will guide you on how to build desktop applications that run on Windows, Mac, and Linux platforms.</p> <p>You will begin your journey with an overview of Electron, and then move on to explore the various stages of creating a simple social media application. Along the way, you will learn how to use advanced Electron APIs, debug an Electron application, and make performance improvements using the Chrome developer tools. You’ll also find out how to package and distribute an application, and more.</p> <p>By the end of the book, you will be able to build a complete desktop application using Electron and web technologies. You will have a solid understanding of the common challenges that desktop app developers face, and you’ll know how to solve them.</p>
Table of Contents (19 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Accessing operating system APIs


Electron applications are a lot like any other desktop application. It sits inside the user's filesystem and you can access it from the Windows start menu or Mac's dock menu. It can trigger any operating system events such as opening the file dialog. Additionally, Electron can present some of the operating system user interface components inside the application such as creating an operating system based menus and context menus. The electron also provides a lot of APIs to access the operating system features, such as:

  • Adding menus to the application window
  • Adding context menus to the application
  • Sending the notifications to the user using operating system notifications system
  • Adding items to the recent items list
  • Custom dock menu and user tasks
  • Progress bar in the taskbar

Unlimited access to Node.js and NPM

Electron provides direct access to Node.js APIs as well as NPM modules from web pages inside the application. Unlike normal web pages, the entire Node.js runtime is available inside your application. This enables you to use custom node modules and third-party modules without any additional effort. You can also use compiled Node.js native modules, which are usually written in C or C++.

What do I need to know?

If you are a web developer then you already know how to develop an Electron application. You don't need any experience in developing desktop applications. You should be comfortable with HTML, CSS, and JavaScript. It's helpful if you know the basics of Node.js and how the module system works in Node.js.

Who uses Electron?

Major companies and developers are already using Electron for their application development. You can find a long list of applications on the Electron showcase page (http://electron.atom.io/apps). There is also a community effort called awesome Electron (https://github.com/sindresorhus/awesome-electron/blob/master/readme.md) where you can get a list of apps with Electron. Awesome Electron not only lists apps but also a lot of resources and library information is available on that page.

It was originally developed as the foundation for the atom editor. Later, a lot of companies started using it for their production applications. Facebook has released a package for atom editor called Nuclide, which is heavily based on Electron:

Screenshot of GitHub Atom editor

In 2015 Microsoft released a source code editor for Windows, Mac, and Linux. This is also based on Electron. It uses Visual Studio Online Monaco editor for creating its editor interface:

Microsoft Visual Studio code

We can have a lot of other examples on Electron-based applications. Nowadays most companies prefer it as their primary desktop application development platform. Here are some popular applications based on Electron:

  • Slack: It's a cloud-based team collaboration tool. It's completely based on web technologies such as React, Redux, ES6/7, and Node.js.
  • Nyla's n1: An open source e-mail client that boasts a great level of flexibility, expandability, and configuration. It's built with Electron and React js. You can find its source code on GitHub (https://github.com/nylas/N1).
  • Wordpress.com: Popular content management system, WordPress uses Electron for their desktop version. It's an open source project and it is available on GitHub (https://github.com/Automattic/wp-desktop).
  • Pixate: It's a mobile app prototyping tool from Google.