You've built your Electron application, and now it's time to share it with the world! This section will guide you through the process of distributing your application, covering both app store submissions and direct downloads. Choosing the right distribution method depends on your target audience and desired reach.
This is the most straightforward approach. You package your application into installers for different operating systems, and then you host these installers on your website or a file-sharing service. Users can then download and install your application directly.
For direct download, you'll primarily use tools that create native installers for Windows, macOS, and Linux. The most popular and recommended tool for this in the Electron ecosystem is electron-builder. It supports a wide range of installer formats and simplifies the packaging process significantly.
npm install electron-builder --save-dev
# or
yarn add electron-builder --devAfter installation, you'll typically configure electron-builder in your package.json file. This configuration tells electron-builder how to build your application for different platforms and what installer types to create.
{
"name": "my-electron-app",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"build": "electron-builder"
},
"devDependencies": {
"electron-builder": "^24.0.0",
"electron": "^25.0.0"
},
"build": {
"appId": "com.yourcompany.myelectronapp",
"productName": "My Electron App",
"files": [
"**/*",
"!node_modules/**"
],
"directories": {
"output": "build",
"app": "."
},
"win": {
"target": "nsis"
},
"mac": {
"target": "dmg"
},
"linux": {
"target": "AppImage"
}
}
}