Top Related Projects
:electron: A complete tool for building and publishing Electron applications
:electron: 🚀 The easiest way to get started with Electron
Explore the Electron APIs
Make any web page a desktop application
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Portable and lightweight cross-platform desktop application development framework
Quick Overview
Electron Quick Start is a minimal Electron application template provided by the Electron team. It serves as a starting point for developers to build cross-platform desktop applications using web technologies like HTML, CSS, and JavaScript.
Pros
- Easy to set up and get started with Electron development
- Provides a basic structure for an Electron app, including main process and renderer process files
- Includes a simple example of inter-process communication (IPC)
- Comes with a pre-configured package.json for easy dependency management and scripts
Cons
- Very basic template, lacking advanced features or best practices for larger applications
- Does not include any UI frameworks or additional tools commonly used in Electron development
- May require significant customization for more complex applications
- Limited documentation within the repository itself
Code Examples
- Main process file (main.js):
const { app, BrowserWindow } = require('electron')
const path = require('path')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
win.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
This code sets up the main process, creates a browser window, and handles basic app lifecycle events.
- Preload script (preload.js):
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
This preload script demonstrates how to safely expose Node.js functionality to the renderer process.
- Renderer process (index.html):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>
</html>
This HTML file serves as the entry point for the renderer process, displaying basic information about the Electron environment.
Getting Started
-
Clone the repository:
git clone https://github.com/electron/electron-quick-start
-
Install dependencies:
cd electron-quick-start npm install
-
Run the application:
npm start
This will launch the Electron app, displaying a window with the "Hello World!" message and version information for Node.js, Chromium, and Electron.
Competitor Comparisons
:electron: A complete tool for building and publishing Electron applications
Pros of Forge
- Provides a more comprehensive project setup with build and packaging tools
- Includes templates for various frameworks (React, Vue, etc.)
- Offers a CLI for easier project management and configuration
Cons of Forge
- Steeper learning curve due to additional features and complexity
- May include unnecessary dependencies for simpler projects
- Requires more configuration for customization
Code Comparison
electron-quick-start:
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Forge:
const { app, BrowserWindow } = require('electron');
const path = require('path');
if (require('electron-squirrel-startup')) app.quit();
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
};
app.on('ready', createWindow);
The Forge example includes additional setup for packaging and distribution, while electron-quick-start provides a minimal boilerplate for getting started quickly.
:electron: 🚀 The easiest way to get started with Electron
Pros of Fiddle
- More comprehensive and feature-rich IDE-like environment for Electron development
- Includes built-in examples and templates for quick learning and prototyping
- Allows easy sharing and collaboration through gists
Cons of Fiddle
- Larger and more complex project, potentially overwhelming for beginners
- Requires more setup and resources compared to the minimal quick-start
Code Comparison
electron-quick-start:
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Fiddle:
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadURL(`file://${__dirname}/index.html`)
}
app.on('ready', createWindow)
The core structure is similar, but Fiddle offers more advanced features and customization options within its IDE environment. electron-quick-start provides a minimal setup for getting started quickly, while Fiddle offers a more comprehensive development experience with additional tools and examples built-in.
Explore the Electron APIs
Pros of electron-api-demos
- More comprehensive, showcasing various Electron APIs and features
- Includes interactive examples and explanations for better learning
- Provides a more polished and user-friendly interface
Cons of electron-api-demos
- Larger project size, potentially overwhelming for beginners
- More complex structure, requiring more time to understand and navigate
- May include unnecessary features for simple projects
Code Comparison
electron-quick-start:
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
electron-api-demos:
const path = require('path')
const glob = require('glob')
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const app = electron.app
const debug = /--debug/.test(process.argv[2])
if (process.mas) app.setName('Electron APIs')
electron-quick-start provides a minimal setup for an Electron app, making it ideal for beginners or quick prototypes. It focuses on the core functionality of creating a window and loading an HTML file.
electron-api-demos offers a more extensive exploration of Electron's capabilities, including various APIs and features. It uses additional dependencies and has a more complex structure, making it better suited for developers looking to dive deeper into Electron's functionality.
Make any web page a desktop application
Pros of Nativefier
- Simplifies the process of creating desktop applications from web apps
- Offers a command-line interface for quick app generation
- Provides additional features like automatic updates and custom icons
Cons of Nativefier
- Less flexibility for customizing the application's behavior
- Limited control over the underlying Electron configuration
- May not be suitable for complex applications requiring deep integration
Code Comparison
Electron-quick-start (main.js):
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Nativefier (command-line usage):
nativefier --name "My App" --icon icon.png "https://mywebsite.com"
The Electron-quick-start repository provides a basic template for creating Electron applications, offering more control and customization options. It requires manual setup and coding but allows for greater flexibility in application development.
Nativefier, on the other hand, focuses on quickly converting web applications into desktop apps with minimal configuration. It's ideal for simple use cases but may not be suitable for more complex applications that require extensive customization or native integrations.
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Pros of Tauri
- Smaller application size due to native system components
- Better performance and lower resource usage
- Cross-platform development with Rust backend
Cons of Tauri
- Steeper learning curve, especially for developers new to Rust
- Smaller ecosystem and community compared to Electron
- Limited access to certain native APIs
Code Comparison
Tauri (main.rs):
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
fn main() {
tauri::Builder::default()
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Electron (main.js):
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Both frameworks allow developers to create desktop applications using web technologies, but they differ in their approach and underlying architecture. Tauri uses Rust for its backend, resulting in smaller, more efficient applications, while Electron relies on Chromium and Node.js, offering a larger ecosystem but at the cost of increased resource usage and application size.
Portable and lightweight cross-platform desktop application development framework
Pros of Neutralinojs
- Significantly smaller application size due to not bundling a full Chromium runtime
- Lower memory usage and faster startup times
- Cross-platform support for desktop and mobile applications
Cons of Neutralinojs
- Less mature ecosystem and community compared to Electron
- Fewer built-in APIs and features, requiring more custom development
- Limited debugging tools and developer experience
Code Comparison
Neutralinojs:
// main.js
Neutralino.init();
Neutralino.events.on("windowClose", () => {
Neutralino.app.exit();
});
Electron Quick Start:
// main.js
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Both frameworks allow developers to create desktop applications using web technologies. Neutralinojs focuses on lightweight, efficient applications with a smaller footprint, while Electron Quick Start provides a more robust set of features and APIs out of the box. The code comparison shows the basic setup for each framework, with Neutralinojs using a simpler initialization process and Electron requiring more boilerplate code to create a window and load content.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
electron-quick-start
Clone and run for a quick way to see Electron in action.
This is a minimal Electron application based on the Quick Start Guide within the Electron documentation.
A basic Electron application needs just these files:
package.json
- Points to the app's main file and lists its details and dependencies.main.js
- Starts the app and creates a browser window to render HTML. This is the app's main process.index.html
- A web page to render. This is the app's renderer process.preload.js
- A content script that runs before the renderer process loads.
You can learn more about each of these components in depth within the Tutorial.
To Use
To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:
# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start
Note: If you're using Linux Bash for Windows, see this guide or use node
from the command prompt.
Resources for Learning Electron
- electronjs.org/docs - all of Electron's documentation
- Electron Fiddle - Electron Fiddle, an app to test small Electron experiments
License
Top Related Projects
:electron: A complete tool for building and publishing Electron applications
:electron: 🚀 The easiest way to get started with Electron
Explore the Electron APIs
Make any web page a desktop application
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Portable and lightweight cross-platform desktop application development framework
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot