SlideShare uma empresa Scribd logo
1 de 45
#codesquad Esinniobiwa Quareeb
Esinniobiwa Quareeb
(Dev Esin)
Myself
devesin1
devesin1
devesin1
devesin
What I do
FullStack Developer, Facilitator and
Technical Writer
 Founder, Author & Mobile Apps Developer
at Devplus Evolution
 Web Application Developer at Qingdom
Technologies
 Trainer & Instructor at FoundersHub
#CodeSquad
DO YOU HAVE AN IDEA OF:
HTML
CSS
JAVASCRIPT
Requirement
Passion and Fuel (e.g. Coffee)
Yea, you’re good to go
#CodeSquad
Developers
Meetup
http://bit.ly/codesquadmu
#CodeSquad
Desktop Apps
An application that runs stand
alone in a desktop or laptop
computer. Contrast with "Web-
based application," which
requires the Web browser to
run. The term may be used to
contrast desktop applications
with mobile applications that
run in smartphones and
tablets.
Desktop Apps with Electron
Let Electron do the hard work for you while
you sit back, watch and sip your coffee
Been in existence since 2013
Github released Atom-Shell, the core of its famous
open-source editor Atom, and renamed it
to Electron for the special occasion.
Electron, unlike other competitors in the category of
Node.js-based desktop applications, brings its own
twist to this already well-established market by
combining the power of Node.js (io.js until recent
releases) with the Chromium Engine to bring us the
best of both server and client-side JavaScript.
Imagine a world where we could build performant,
data-driven, cross-platform desktop applications
powered by not only the ever-growing repository of
NPM modules, but also the entire Bower registry to
fulfill all our client-side needs.
Electron
PROS:
• HTML + CSS + JS
• NodeJs + Chrome
• No deplyoment Dependencies
Electron
CONS:
• HTML + CSS + JS
• JavaScript
• Native Module in C/C++
Electron Features
• Rapid Development
• Themes
• Shared Code/UI
• Deployment + Silent Updates
• Native UX
Popular Apps that are built on electron
Let’s get started
Make sure that nodejs is installed as well as
electron. To check, open command line and type
node –v
electron –v
New to node, it is easy, just dive to
https://nodejs.org
And download the latest version of nodejs
Todo 1
• Make sure you’re in the desired directory, In my
own case, I use desktop, so fire up your
command line, navigate to the directory and it
should be something like this
Todo 2
• Create a directory where your project will
reside. On windows you can use mkdir
command like this
mkdir testapps
This will create a folder named testapps on
desktop.
Then go inside the directory using this
command:
cd testapps
So far you should have this
This means
• you’re on desktop
• You’ve successfully created a folder named testapps where your project will
reside and
• You’re inside the testapps folder to begin operation
NOTE: Please don’t close the command line, if you have to test your progress, just
minimize it and go back their later, it doesn’t have effect, it will just save you time to
have to navigate to the directory all over again
Set up your apps
Initialize your apps with this command
npm init
This will ask your information about
your apps and then create
package.json file inside folder testapps
You should have this, once you fill out
the entries:
Keynote 1
• Press enter key if what the command line
suggested is what you want to use, else type
your desired entries.
Example, npm suggested testapps as the name of
my project, since it is okay by me, I pressed enter
key.
You can later change the properties in
package.json file
• So far, package.json file has been created for us,
which contain information about the apps.
• Index.js is the entrypoint, that is where we will
define our project details and initialize electron
Install electron in your current
directory
using command line type:
npm install electron -save --dev --verbose
The command is pretty straight-forward.
--verbose is used to display information about
the installation process since it can take a while,
and you’d want to be sure it hasn’t stopped
working.
If everything worked fine, you should
have this:
Now in your testapps folder, you
should have a file and a folder
• Package.json file
• node_modules folder
You can play around with package.json file
Please don’t touch the node_modules folder
Fire up your text editor to create index.js file
Recall: That’s your project entry point
Put these codes in your index.js file
const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
var myWindow;
app.on('ready',function(){
myWindow = new BrowserWindow({width: 800,
height: 720});
//myWindow.loadURL('https://google.com');
myWindow.loadURL('file://' + __dirname +
'/index.html');
});
Explanation
• First, we include electron using the require
statement, then electron object returned by the line
1, then we create the app object, this will represent
our application and we can just be assigning values
to it later on.
• Second, we create application window, where the
app will be loaded using BrowserWindow object in
electron.
• Then define window object using
var mainWindow;
• Then, we bind the app with ready event when your
app is loaded
Explanation cont’d
• Then define properties for your myWindow object,
we can give it many properties
Height, Width, "use-content-size": false, resizable:
true, center: true and many more
You can load a webpage using loadURL and you can as
well load your index.html file
NOTE: To load the url, comment out
//mainWindow.loadURL('file://' + __dirname +
'/index.html');
And to load the index.html file, comment out
//mainWindow.loadURL('https://google.com');
Then, modify the package.json file, change the line
"test": "echo "Error: no test specified" && exit 1“
To
"start": "electron . "
This is to execute electron app at the specified
location
Create a sample index.html page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Electron Apps</title>
</head>
<body>
<header>
<h1 style="text-align: center;">Electron Apps</h1>
</header>
<main>
<p style="text-align: center; font-size: 24px" > I am a sample web page, I
can be built using <b>HTML</b>, <b>CSS</b> and <b>JS</b>, packaged with
<b>Electron</b></p>
</main>
</body>
</html>
Then go to command line and type
npm start
This will execute the “ electron . ” Specified in
package.json
If everything works fine without errors, you will see
the interface in the next slide
To Package the Apps
Use electron-packager, In the command line type:
npm install electron-packager
This may take a while, after successful installation,
start electron-packager using
electron-packager .
The first command will install electron-packager
inside the node_modules folder
The second command will write executable of your
apps targetting the machine you’re building on
“electron-packager .” will build the
executable of your files targetting the
machine you’re working on.
The downside is that, your source code will be
displayed alongside the executable, in order to
make our source code hidden, use
electron-packager . --asar
--asar will create asar files for your source code so
that it won’t be visible to prying eyes
The folder structure should look like
this
“testapps-win32-x64” folder contain the executable file and
other accompanying files
For all platforms deployment
electron-packager . --all
This will deploy for all platforms, although this
may take a while
How To:
Executable
and
Installable
Electron packager build installable for
you
There are quite lots of apps out their to
create installer for your apps. Example
• Install Creator
• Install Forge
And many more
In this case, we’ll be using #Installforge
Let’s go back and Test
If you have an existing web project
that you want to turn desktop apps
• Just open commandline in the directory.
• Initialize npm and follow the procedure
• In no time you will get your executable file.
For more information and documentation,
https://electron.atom.io/
Thanks for Listening
Information about building installable
package for your apps will be made
available on request.
The apps created with electron, with
this slides and detailed information
are on this github repository
https://github.com/devesin/electron-typingmaster
devesindevesindevesin1
Screenshot of the typing practice apps
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron

Mais conteúdo relacionado

Mais procurados

Best Practice-React
Best Practice-ReactBest Practice-React
Best Practice-React
Yang Yang
 

Mais procurados (20)

Reactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.NetReactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.Net
 
Electron - Solving our cross platform dreams?
Electron - Solving our cross platform dreams?Electron - Solving our cross platform dreams?
Electron - Solving our cross platform dreams?
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Kruize
KruizeKruize
Kruize
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Best Practice-React
Best Practice-ReactBest Practice-React
Best Practice-React
 
How to setup jenkins
How to setup jenkinsHow to setup jenkins
How to setup jenkins
 
More Modern Perl - YAPC 2016
More Modern Perl - YAPC 2016More Modern Perl - YAPC 2016
More Modern Perl - YAPC 2016
 
The Price of Fixing One Bug in Our Programs, or Exotic Bugs in PVS-Studio and...
The Price of Fixing One Bug in Our Programs, or Exotic Bugs in PVS-Studio and...The Price of Fixing One Bug in Our Programs, or Exotic Bugs in PVS-Studio and...
The Price of Fixing One Bug in Our Programs, or Exotic Bugs in PVS-Studio and...
 
Evented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHPEvented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHP
 
Meet Puppet's new product lineup 12/7/2017
Meet Puppet's new product lineup 12/7/2017Meet Puppet's new product lineup 12/7/2017
Meet Puppet's new product lineup 12/7/2017
 
Continuous integration of_puppet_code
Continuous integration of_puppet_codeContinuous integration of_puppet_code
Continuous integration of_puppet_code
 
code-camp-meteor
code-camp-meteorcode-camp-meteor
code-camp-meteor
 
Web Hooks
Web HooksWeb Hooks
Web Hooks
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Writing a npm module
Writing a npm moduleWriting a npm module
Writing a npm module
 
Building and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and ContextBuilding and Deployment of Drupal sites with Features and Context
Building and Deployment of Drupal sites with Features and Context
 
Puppet - an introduction
Puppet - an introductionPuppet - an introduction
Puppet - an introduction
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18
 
Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2 Selenium Training in Chennai Demo Part-2
Selenium Training in Chennai Demo Part-2
 

Destaque

Gerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233SGerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
MCExorzist
 
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewFrom Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
Italo Mairo
 
Angela Merkel - Doktorarbeit
Angela Merkel - DoktorarbeitAngela Merkel - Doktorarbeit
Angela Merkel - Doktorarbeit
MCExorzist
 

Destaque (20)

Muammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne BuchMuammar al-Gaddafi - Das Grüne Buch
Muammar al-Gaddafi - Das Grüne Buch
 
JS Class 2016
JS Class 2016JS Class 2016
JS Class 2016
 
Politische Ponerologie
Politische PonerologiePolitische Ponerologie
Politische Ponerologie
 
Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)Real History - The Bad War (english 115s)
Real History - The Bad War (english 115s)
 
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233SGerd Honsik - Freispruch für Hitler - 1988 - 233S
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
 
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi GermanyThomas Goodrich - Hellstorm The Death Of Nazi Germany
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
 
JavaScript - The Universal Platform?
JavaScript - The Universal Platform?JavaScript - The Universal Platform?
JavaScript - The Universal Platform?
 
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course OverviewFrom Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
From Drupal 7 to Drupal 8 - Drupal Intensive Course Overview
 
Angela Merkel - Doktorarbeit
Angela Merkel - DoktorarbeitAngela Merkel - Doktorarbeit
Angela Merkel - Doktorarbeit
 
Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)Cross-Platform Desktop Apps with Electron (JSConf UY)
Cross-Platform Desktop Apps with Electron (JSConf UY)
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
 
Electron
ElectronElectron
Electron
 
JavaScript and Desktop Apps - Introduction to Electron
JavaScript and Desktop Apps - Introduction to ElectronJavaScript and Desktop Apps - Introduction to Electron
JavaScript and Desktop Apps - Introduction to Electron
 
RESTful application with Drupal 8
RESTful application with Drupal 8RESTful application with Drupal 8
RESTful application with Drupal 8
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularNativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
 
Audiobooks and the Sound of Sales - Noah Genner - Tech Forum 2017
Audiobooks and the Sound of Sales - Noah Genner - Tech Forum 2017Audiobooks and the Sound of Sales - Noah Genner - Tech Forum 2017
Audiobooks and the Sound of Sales - Noah Genner - Tech Forum 2017
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
 
Electron - Build cross platform desktop apps
Electron - Build cross platform desktop appsElectron - Build cross platform desktop apps
Electron - Build cross platform desktop apps
 
JS class slides (2016)
JS class slides (2016)JS class slides (2016)
JS class slides (2016)
 

Semelhante a Cross-platform Desktop Apps development using HTML, CSS, JS with Electron

Documenting apps ti confnyc
Documenting apps   ti confnycDocumenting apps   ti confnyc
Documenting apps ti confnyc
Jamil Spain
 
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docxPart 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
karlhennesey
 

Semelhante a Cross-platform Desktop Apps development using HTML, CSS, JS with Electron (20)

How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications
 
Database Management Assignment Help
Database Management Assignment Help Database Management Assignment Help
Database Management Assignment Help
 
How java works
How java worksHow java works
How java works
 
How java works
How java worksHow java works
How java works
 
Class 1
Class 1Class 1
Class 1
 
Class 1
Class 1Class 1
Class 1
 
TiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium ApplicationsTiConf NYC - Documenting Your Titanium Applications
TiConf NYC - Documenting Your Titanium Applications
 
Documenting apps ti confnyc
Documenting apps   ti confnycDocumenting apps   ti confnyc
Documenting apps ti confnyc
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
 
ReactJS software installation
ReactJS software installationReactJS software installation
ReactJS software installation
 
Start your adventure with docker
Start your adventure with dockerStart your adventure with docker
Start your adventure with docker
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodology
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Android app upload
Android app uploadAndroid app upload
Android app upload
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Gaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docxGaganjot Kaur- The Nx Workspace.docx
Gaganjot Kaur- The Nx Workspace.docx
 
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docxPart 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
Part 4 Scripting and Virtualization (due Week 7)Objectives1. .docx
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Cross-platform Desktop Apps development using HTML, CSS, JS with Electron

  • 3. What I do FullStack Developer, Facilitator and Technical Writer  Founder, Author & Mobile Apps Developer at Devplus Evolution  Web Application Developer at Qingdom Technologies  Trainer & Instructor at FoundersHub #CodeSquad
  • 4. DO YOU HAVE AN IDEA OF: HTML CSS JAVASCRIPT Requirement Passion and Fuel (e.g. Coffee) Yea, you’re good to go #CodeSquad
  • 6. Desktop Apps An application that runs stand alone in a desktop or laptop computer. Contrast with "Web- based application," which requires the Web browser to run. The term may be used to contrast desktop applications with mobile applications that run in smartphones and tablets.
  • 7. Desktop Apps with Electron
  • 8. Let Electron do the hard work for you while you sit back, watch and sip your coffee
  • 9. Been in existence since 2013 Github released Atom-Shell, the core of its famous open-source editor Atom, and renamed it to Electron for the special occasion. Electron, unlike other competitors in the category of Node.js-based desktop applications, brings its own twist to this already well-established market by combining the power of Node.js (io.js until recent releases) with the Chromium Engine to bring us the best of both server and client-side JavaScript. Imagine a world where we could build performant, data-driven, cross-platform desktop applications powered by not only the ever-growing repository of NPM modules, but also the entire Bower registry to fulfill all our client-side needs.
  • 10.
  • 11. Electron PROS: • HTML + CSS + JS • NodeJs + Chrome • No deplyoment Dependencies
  • 12. Electron CONS: • HTML + CSS + JS • JavaScript • Native Module in C/C++
  • 13. Electron Features • Rapid Development • Themes • Shared Code/UI • Deployment + Silent Updates • Native UX
  • 14.
  • 15. Popular Apps that are built on electron
  • 16. Let’s get started Make sure that nodejs is installed as well as electron. To check, open command line and type node –v electron –v New to node, it is easy, just dive to https://nodejs.org And download the latest version of nodejs
  • 17. Todo 1 • Make sure you’re in the desired directory, In my own case, I use desktop, so fire up your command line, navigate to the directory and it should be something like this
  • 18. Todo 2 • Create a directory where your project will reside. On windows you can use mkdir command like this mkdir testapps This will create a folder named testapps on desktop. Then go inside the directory using this command: cd testapps
  • 19. So far you should have this This means • you’re on desktop • You’ve successfully created a folder named testapps where your project will reside and • You’re inside the testapps folder to begin operation NOTE: Please don’t close the command line, if you have to test your progress, just minimize it and go back their later, it doesn’t have effect, it will just save you time to have to navigate to the directory all over again
  • 20. Set up your apps Initialize your apps with this command npm init This will ask your information about your apps and then create package.json file inside folder testapps
  • 21. You should have this, once you fill out the entries:
  • 22. Keynote 1 • Press enter key if what the command line suggested is what you want to use, else type your desired entries. Example, npm suggested testapps as the name of my project, since it is okay by me, I pressed enter key. You can later change the properties in package.json file • So far, package.json file has been created for us, which contain information about the apps. • Index.js is the entrypoint, that is where we will define our project details and initialize electron
  • 23. Install electron in your current directory using command line type: npm install electron -save --dev --verbose The command is pretty straight-forward. --verbose is used to display information about the installation process since it can take a while, and you’d want to be sure it hasn’t stopped working.
  • 24. If everything worked fine, you should have this:
  • 25. Now in your testapps folder, you should have a file and a folder • Package.json file • node_modules folder You can play around with package.json file Please don’t touch the node_modules folder Fire up your text editor to create index.js file Recall: That’s your project entry point
  • 26. Put these codes in your index.js file const electron = require("electron"); const app = electron.app; const BrowserWindow = electron.BrowserWindow; var myWindow; app.on('ready',function(){ myWindow = new BrowserWindow({width: 800, height: 720}); //myWindow.loadURL('https://google.com'); myWindow.loadURL('file://' + __dirname + '/index.html'); });
  • 27. Explanation • First, we include electron using the require statement, then electron object returned by the line 1, then we create the app object, this will represent our application and we can just be assigning values to it later on. • Second, we create application window, where the app will be loaded using BrowserWindow object in electron. • Then define window object using var mainWindow; • Then, we bind the app with ready event when your app is loaded
  • 28. Explanation cont’d • Then define properties for your myWindow object, we can give it many properties Height, Width, "use-content-size": false, resizable: true, center: true and many more You can load a webpage using loadURL and you can as well load your index.html file NOTE: To load the url, comment out //mainWindow.loadURL('file://' + __dirname + '/index.html'); And to load the index.html file, comment out //mainWindow.loadURL('https://google.com');
  • 29. Then, modify the package.json file, change the line "test": "echo "Error: no test specified" && exit 1“ To "start": "electron . " This is to execute electron app at the specified location
  • 30. Create a sample index.html page <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Electron Apps</title> </head> <body> <header> <h1 style="text-align: center;">Electron Apps</h1> </header> <main> <p style="text-align: center; font-size: 24px" > I am a sample web page, I can be built using <b>HTML</b>, <b>CSS</b> and <b>JS</b>, packaged with <b>Electron</b></p> </main> </body> </html>
  • 31. Then go to command line and type npm start This will execute the “ electron . ” Specified in package.json If everything works fine without errors, you will see the interface in the next slide
  • 32.
  • 33.
  • 34. To Package the Apps Use electron-packager, In the command line type: npm install electron-packager This may take a while, after successful installation, start electron-packager using electron-packager . The first command will install electron-packager inside the node_modules folder The second command will write executable of your apps targetting the machine you’re building on
  • 35. “electron-packager .” will build the executable of your files targetting the machine you’re working on. The downside is that, your source code will be displayed alongside the executable, in order to make our source code hidden, use electron-packager . --asar --asar will create asar files for your source code so that it won’t be visible to prying eyes
  • 36. The folder structure should look like this “testapps-win32-x64” folder contain the executable file and other accompanying files
  • 37. For all platforms deployment electron-packager . --all This will deploy for all platforms, although this may take a while
  • 39. Electron packager build installable for you There are quite lots of apps out their to create installer for your apps. Example • Install Creator • Install Forge And many more In this case, we’ll be using #Installforge
  • 40.
  • 41. Let’s go back and Test
  • 42. If you have an existing web project that you want to turn desktop apps • Just open commandline in the directory. • Initialize npm and follow the procedure • In no time you will get your executable file. For more information and documentation, https://electron.atom.io/
  • 43. Thanks for Listening Information about building installable package for your apps will be made available on request. The apps created with electron, with this slides and detailed information are on this github repository https://github.com/devesin/electron-typingmaster devesindevesindevesin1
  • 44. Screenshot of the typing practice apps