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

Preface

This book guides readers through building desktop applications that runs on Windows, Mac, and Linux platforms using the GitHub Electron framework. The book describes how to use your existing web development skills to build a cross-platform desktop application using HTML, CSS, and JavaScript.

Electron is one of the most popular frameworks for creating cross-platform desktop applications using JavaScript and Node.js. It’s built on top of the Google's chromium project. Nowadays, it’s getting more popular and companies and developers are using it for their production applications.

In this book, we’ll talk through everything from installing tools, writing the application, and using various third-party tools and frameworks along with Electron.

What this book covers

Chapter 1, Introducing Electron, gives a basic overview about Electron and explains the internals of the Electron. Here, we will be seeing how Electron works and the architecture of the Electron.

Chapter 2, Building Your First Electron Application, discusses the step-by-step guide to develop an Electron application. It covers the steps to create a simple application from environmental setup to running the application.

Chapter 3, Tooling and Debugging, is all about tooling and debugging the application. It gives a detailed idea about debugging the application using various tools and IDEs that are available today.

Chapter 4, Using Angular 2 with Electron, explains using Angular 2 and TypeScript for creating the user interface for Electron application. The chapter will also discuss some other new technologies that are trending today. It will provide you with a detailed idea about using modern frontend frameworks and technologies with your Electron application.

Chapter 5, Crafting User Interface, showcases creating user interfaces for Electron applications. We will be covering various UI frameworks and some of the Electron-based UI frameworks, such as Photon, in this chapter. The chapter will be also covering how to use the popular React framework to craft your user interface for an Electron application.

Chapter 6, Using Node.js with Electron, teaches you how to use the Node.js context that is available inside the Electron in your project. This will be providing you with a complete guide to use the Node.js APIs inside an Electron application.

Chapter 7, Deep Dive into Electron API - 1, gives a detailed idea about various Electron APIs. We will be covering Electron APIs such as Clipboard, Process, Shell, Image, File, Dialog, Accelerator, and Session. This chapter will also cover some advanced topics, such as request intercepting and custom protocol implementation.

Chapter 8, Exploring Electron API – 2, continues exploring various Electron APIs. This will cover some of the advanced features, such as webContents API, which is used to control the rendering process, possible Chrome command-line switches, and the download API, among other things.

Chapter 9, Integrating with Desktop Environments, shows that different operating systems provide different features for integrating desktop applications into their desktop environments. This chapter explains how to integrate our application into those desktop environments with Electron APIs.

Chapter 10, Dealing with Web Standards, focuses on how various web standards can be integrated with Electron. This will cover topics such as caching network resources using a service worker, using local storage, and persisting data using IndexedDB.

Chapter 11, Testing Electron Application, informs that testing is an important aspect of the software application development process. This chapter covers testing your Electron application. The chapter also covers how to use popular JavaScript testing frameworks and, also, how to use those frameworks inside the Electron application.

Chapter 12, Packaging and Distributing the Application, explains how to package the application for final production. We will cover various libraries to package and distribute our application. This section will describe how to move to native packaging for each platform, how to enable autoupdating for the application in case of new changes, creating ASAR packages, creating installers for each platform, and guidelines to submit to various stores.

What you need for this book

  • A text editor to edit and create HTML, CSS, and JavaScript files; you can use your preferred editor.
  • Node.js should be installed in your system, at least 4.x or later version should be installed. It is preferable to have at least 6.x and later version.
  • A package manager such as npm or yarn; npm will be installed by default when you install Node.js.
  • (Optional) Git client should be installed on your computer if you would like to check out the recipe source code directly from our Git repository.

Who this book is for

If you are a developer familiar with HTML, CSS, and JavaScript, and you wish to develop a desktop application using these technologies, then this book is for you. This book is also targeting experienced JavaScript developers with a basic understanding of frontend development and Node.js development. This book is also suitable for frontend/web developers who want to develop a desktop application using the same technologies they are using for web development.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Electron then loads the HTML page using the loadurl function."

A block of code is set as follows:

{
   "name"    : "your-app",
   "version" : "0.1.0",
   "main"    : "main.js"
}

Any command-line input or output is written as follows:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text surrounded by quotes, or like this: "Just hit the Download button and click OK."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us, as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Building-Cross-Platform-Desktop-Applications-with-Electron. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book 

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/BuildingCross-PlatformDesktopApplicationswithElectron_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.