How to Create a Desktop App Using JavaScript? Last Updated : 08 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Building a JavaScript desktop application is possible using various frameworks and technologies. One popular approach is to use Electron, which is an open-source framework developed by GitHub. Electron allows you to build cross-platform desktop applications using web technologies such as HTML, CSS, and JavaScript. In this article, we are going to use JavaScript for a desktop app.Prerequisites:Node.js and npmSteps to build a desktop app using JavaScript and Electron:Step 1: Install Node.js and npmMake sure you have Node.js and npm (Node Package Manager) installed on your machine. You can download them from the official website: Node.jsStep 2: Create a new project:Create a new directory for your project and navigate into it in the terminal.mkdir my-electron-app cd my-electron-appStep 3: Initialize a new Node.js projectRun the following command to initialize a new package.json file.npm init -yStep 4: Install ElectronInstall Electron as a development dependency using npm.npm install electron --save-devStep 5: Create main and renderer processes:In your project directory, create two files, main.js and index.html. main.js will be the main process, and index.html will be the renderer process.Example: This example shows the creation of a desktop app. HTML <!-- index.html --> <!DOCTYPE html> <html> <head> <title>Desktop App</title> </head> <body> <h1>Hello, Geeks!</h1> </body> </html> JavaScript //main.js const { app, BrowserWindow } = require('electron'); let mainWindow; function createWindow() { mainWindow = new BrowserWindow({ width: 400, height: 300, webPreferences: { nodeIntegration: true, }, }); mainWindow.loadFile('index.html'); mainWindow.on('closed', function () { mainWindow = null; }); } app.whenReady().then(createWindow); app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); }); app.on('activate', function () { if (mainWindow === null) createWindow(); }); Step 6: Update package.json:Modify the scripts section in your package.json file to include a start script."scripts": { "start": "electron main.js" },Step 7: Run your Electron app:Execute the following command to run your Electron app.npm startThis will launch your desktop application with Electron. You can further customize and enhance your app by exploring the Electron API and integrating additional packages as needed.Output: Comment More infoAdvertise with us Next Article Environment Variables in ElectronJS A amanv09 Follow Improve Article Tags : JavaScript Web Technologies ElectronJS Similar Reads Introduction to ElectronJS Creating cross-platform applications often requires learning multiple programming languages and frameworks. However, Electron.js eliminates this complexity by allowing developers to build desktop applications using familiar web technologies like JavaScript, HTML, and CSS.In this article, we will lea 5 min read How to Create a Desktop App Using JavaScript? Building a JavaScript desktop application is possible using various frameworks and technologies. One popular approach is to use Electron, which is an open-source framework developed by GitHub. Electron allows you to build cross-platform desktop applications using web technologies such as HTML, CSS, 2 min read Environment Variables in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime. 7 min read Manage Staging Environments in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.I 6 min read Integrate Angular 7 with ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime. 8 min read Command Line Arguments in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime. 6 min read Keyboard Shortcuts in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.U 6 min read Windows Taskbar Operations in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.A 6 min read File Upload in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime. 8 min read Managing Themes in ElectronJS ElectronJS is an Open Source Framework used for building Cross-Platform native desktop applications using web technologies such as HTML, CSS, and JavaScript which are capable of running on Windows, macOS, and Linux operating systems. It combines the Chromium engine and NodeJS into a Single Runtime.T 9 min read Like