{"id":2075,"date":"2025-08-22T13:30:04","date_gmt":"2025-08-22T13:30:04","guid":{"rendered":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/"},"modified":"2025-08-22T13:30:04","modified_gmt":"2025-08-22T13:30:04","slug":"getting-started-with-electron-your-first-hello-world-app","status":"publish","type":"post","link":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/","title":{"rendered":"Getting Started with Electron: Your First &#8220;Hello, World&#8221; App"},"content":{"rendered":"<h1>Getting Started with Electron: Your First &#8220;Hello, World&#8221; App<\/h1>\n<p>Ready to dive into the world of desktop application development with JavaScript? \ud83d\ude80 Look no further! This tutorial, <strong>Electron Hello World App Tutorial<\/strong>, will guide you through creating your very first Electron application, a classic &#8220;Hello, World&#8221; example. Electron allows you to build cross-platform desktop applications using web technologies like HTML, CSS, and JavaScript.  We&#8217;ll break down the process step-by-step, making it easy for even complete beginners to understand.<\/p>\n<h2>Executive Summary \ud83c\udfaf<\/h2>\n<p>This tutorial provides a practical introduction to Electron, a powerful framework for building cross-platform desktop applications using web technologies. We&#8217;ll focus on creating a simple &#8220;Hello, World&#8221; application, covering essential concepts such as the main process, renderer process, and inter-process communication (IPC). By the end of this guide, you&#8217;ll have a functional Electron app and a solid foundation for building more complex applications. The tutorial includes detailed code examples and explanations, ensuring a smooth learning experience. We&#8217;ll also touch upon packaging and distribution, giving you a complete overview of the Electron development workflow. Think of it as a starting point for turning your web development skills into desktop app magic! \u2728 Get ready to elevate your coding skills and build amazing desktop apps with Electron! \ud83d\udcc8<\/p>\n<h2>Project Setup and Dependencies<\/h2>\n<p>Setting up your project correctly is crucial for a smooth Electron development experience. This involves initializing your project with Node.js and installing the necessary Electron dependency.<\/p>\n<ul>\n<li>\u2705 Ensure you have Node.js and npm (Node Package Manager) installed on your system. Check versions with <code>node -v<\/code> and <code>npm -v<\/code>.<\/li>\n<li>\u2705 Create a new project directory: <code>mkdir electron-hello-world<\/code> and navigate into it: <code>cd electron-hello-world<\/code>.<\/li>\n<li>\u2705 Initialize your project with npm: <code>npm init -y<\/code>. This creates a <code>package.json<\/code> file.<\/li>\n<li>\u2705 Install Electron as a development dependency: <code>npm install --save-dev electron<\/code>.<\/li>\n<li>\u2705 Create a <code>main.js<\/code> file, which will serve as the entry point for your Electron application.<\/li>\n<\/ul>\n<h2>Creating the Main Process<\/h2>\n<p>The main process is the brain of your Electron application. It controls the application lifecycle, creates windows, and handles system events.<\/p>\n<ul>\n<li>\u2705 In <code>main.js<\/code>, import the necessary modules from Electron: <code>const { app, BrowserWindow } = require('electron')<\/code>.<\/li>\n<li>\u2705 Define a function to create a new window:\n<pre><code class=\"language-javascript\">\nfunction createWindow () {\n  const win = new BrowserWindow({\n    width: 800,\n    height: 600,\n    webPreferences: {\n      nodeIntegration: true, \/\/ Enable Node.js integration in the renderer process\n      contextIsolation: false \/\/ Required for nodeIntegration\n    }\n  })\n\n  win.loadFile('index.html') \/\/ Load your HTML file\n}\n            <\/code><\/pre>\n<\/li>\n<li>\u2705 Use the <code>app.whenReady()<\/code> method to create the window when Electron is ready:\n<pre><code class=\"language-javascript\">\napp.whenReady().then(createWindow)\n            <\/code><\/pre>\n<\/li>\n<li>\u2705 Handle application activation and window closing:\n<pre><code class=\"language-javascript\">\napp.on('window-all-closed', () =&gt; {\n  if (process.platform !== 'darwin') {\n    app.quit()\n  }\n})\n\napp.on('activate', () =&gt; {\n  if (BrowserWindow.getAllWindows().length === 0) {\n    createWindow()\n  }\n})\n            <\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>Building the Renderer Process (UI)<\/h2>\n<p>The renderer process is responsible for rendering the user interface using HTML, CSS, and JavaScript.  It&#8217;s essentially a web page running within the Electron application.<\/p>\n<ul>\n<li>\u2705 Create an <code>index.html<\/code> file in your project directory.<\/li>\n<li>\u2705 Add basic HTML structure:\n<pre><code class=\"language-html\">\n&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;title&gt;Hello World!&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt;Hello World!&lt;\/h1&gt;\n    &lt;p&gt;Welcome to your first Electron application!&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n            <\/code><\/pre>\n<\/li>\n<li>\u2705 You can add CSS to style your application. Create a <code>style.css<\/code> file and link it in <code>index.html<\/code>:\n<pre><code class=\"language-html\">\n&lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n            <\/code><\/pre>\n<\/li>\n<li>\u2705 Add JavaScript to <code>index.html<\/code> or a separate <code>script.js<\/code> file to add interactivity. Remember to enable Node.js integration in the `webPreferences` in `main.js`.<\/li>\n<\/ul>\n<h2>Running Your Electron Application<\/h2>\n<p>With the main and renderer processes set up, you can now run your Electron application to see the &#8220;Hello, World&#8221; message in action.  This involves adding a script to your `package.json` and then running that script.<\/p>\n<ul>\n<li>\u2705 Open your <code>package.json<\/code> file and add a <code>start<\/code> script under the <code>\"scripts\"<\/code> section:\n<pre><code class=\"language-json\">\n\"scripts\": {\n  \"start\": \"electron .\"\n}\n            <\/code><\/pre>\n<\/li>\n<li>\u2705 Run your application from the terminal: <code>npm start<\/code>.<\/li>\n<li>\u2705 You should see a window appear displaying &#8220;Hello World!&#8221; If not, double-check your code and configurations.<\/li>\n<li>\u2705 Congratulations! You&#8217;ve successfully created your first Electron application. \ud83d\udca1<\/li>\n<\/ul>\n<h2>Packaging and Distribution (Optional)<\/h2>\n<p>While optional for a simple &#8220;Hello, World&#8221; app, understanding packaging and distribution is essential for real-world Electron applications.  This allows you to create executable files for different operating systems.<\/p>\n<ul>\n<li>\u2705 Install <code>electron-packager<\/code> or <code>electron-builder<\/code> as a development dependency. For example: <code>npm install --save-dev electron-packager<\/code>.<\/li>\n<li>\u2705 Configure your <code>package.json<\/code> file with packaging options. This typically involves specifying the target platforms, architecture, and app name.<\/li>\n<li>\u2705 Use the packaging tool to create executable files for your desired platforms.  The specific commands will depend on the tool you choose.<\/li>\n<li>\u2705 Distribute your application to users. This may involve creating installers or distributing the executable files directly.<\/li>\n<\/ul>\n<h2>FAQ \u2753<\/h2>\n<h3>What is Electron, and why should I use it?<\/h3>\n<p>Electron is a framework for building cross-platform desktop applications with web technologies like HTML, CSS, and JavaScript. It&#8217;s a great choice because it allows web developers to leverage their existing skills to create desktop apps without learning a new language.  Plus, it&#8217;s used by many popular applications, so you know it&#8217;s reliable.<\/p>\n<h3>What are the main and renderer processes?<\/h3>\n<p>The main process is the entry point of your Electron application and is responsible for managing the application lifecycle and creating windows. The renderer process is like a web browser window and is responsible for rendering the user interface. These processes communicate with each other using IPC (Inter-Process Communication).<\/p>\n<h3>How do I debug my Electron application?<\/h3>\n<p>Debugging Electron applications is similar to debugging web applications. You can use the Chrome DevTools by right-clicking in your application and selecting &#8220;Inspect&#8221;. You can also use the <code>--inspect<\/code> flag when running Electron to attach a debugger. Remember to check both the main and renderer processes for errors.<\/p>\n<h2>Conclusion \u2705<\/h2>\n<p>Congratulations on creating your first Electron &#8220;Hello, World&#8221; application! This <strong>Electron Hello World App Tutorial<\/strong> has provided you with a foundational understanding of Electron development. You&#8217;ve learned how to set up a project, create main and renderer processes, and run your application. This is just the beginning! Explore more advanced features of Electron, such as inter-process communication, native modules, and packaging. The possibilities are endless when you combine the power of web technologies with the capabilities of a desktop environment. Don&#8217;t hesitate to check DoHost <a href=\"https:\/\/dohost.us\">https:\/\/dohost.us<\/a> services for web hosting. Keep practicing and experimenting, and you&#8217;ll be building amazing desktop applications in no time. \ud83d\ude80 This knowledge opens doors to building cross-platform applications, expanding your skill set and career opportunities. \ud83d\udcc8<\/p>\n<h3>Tags<\/h3>\n<p>    Electron, JavaScript, Desktop Application, Cross-Platform, Hello World<\/p>\n<h3>Meta Description<\/h3>\n<p>    Build your first Electron app! This comprehensive tutorial guides you through creating a &#8216;Hello, World&#8217; app, step-by-step. Learn Electron fundamentals.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting Started with Electron: Your First &#8220;Hello, World&#8221; App Ready to dive into the world of desktop application development with JavaScript? \ud83d\ude80 Look no further! This tutorial, Electron Hello World App Tutorial, will guide you through creating your very first Electron application, a classic &#8220;Hello, World&#8221; example. Electron allows you to build cross-platform desktop applications [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7773],"tags":[103,7785,269,7786,1566,7783,7774,7782,7784,4231,18,203],"class_list":["post-2075","post","type-post","status-publish","format-standard","hentry","category-cross-platform-development","tag-application-development","tag-atom","tag-beginner","tag-chromium","tag-cross-platform","tag-desktop-app","tag-electron","tag-electron-tutorial","tag-guide","tag-hello-world","tag-javascript","tag-node-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.0 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting Started with Electron: Your First &quot;Hello, World&quot; App - Developers Heaven<\/title>\n<meta name=\"description\" content=\"Build your first Electron app! This comprehensive tutorial guides you through creating a\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting Started with Electron: Your First &quot;Hello, World&quot; App\" \/>\n<meta property=\"og:description\" content=\"Build your first Electron app! This comprehensive tutorial guides you through creating a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/\" \/>\n<meta property=\"og:site_name\" content=\"Developers Heaven\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-22T13:30:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/via.placeholder.com\/600x400?text=Getting+Started+with+Electron+Your+First+Hello+World+App\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/\",\"url\":\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/\",\"name\":\"Getting Started with Electron: Your First \\\"Hello, World\\\" App - Developers Heaven\",\"isPartOf\":{\"@id\":\"https:\/\/developers-heaven.net\/blog\/#website\"},\"datePublished\":\"2025-08-22T13:30:04+00:00\",\"author\":{\"@id\":\"\"},\"description\":\"Build your first Electron app! This comprehensive tutorial guides you through creating a\",\"breadcrumb\":{\"@id\":\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/developers-heaven.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting Started with Electron: Your First &#8220;Hello, World&#8221; App\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/developers-heaven.net\/blog\/#website\",\"url\":\"https:\/\/developers-heaven.net\/blog\/\",\"name\":\"Developers Heaven\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/developers-heaven.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Getting Started with Electron: Your First \"Hello, World\" App - Developers Heaven","description":"Build your first Electron app! This comprehensive tutorial guides you through creating a","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/","og_locale":"en_US","og_type":"article","og_title":"Getting Started with Electron: Your First \"Hello, World\" App","og_description":"Build your first Electron app! This comprehensive tutorial guides you through creating a","og_url":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/","og_site_name":"Developers Heaven","article_published_time":"2025-08-22T13:30:04+00:00","og_image":[{"url":"https:\/\/via.placeholder.com\/600x400?text=Getting+Started+with+Electron+Your+First+Hello+World+App","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/","url":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/","name":"Getting Started with Electron: Your First \"Hello, World\" App - Developers Heaven","isPartOf":{"@id":"https:\/\/developers-heaven.net\/blog\/#website"},"datePublished":"2025-08-22T13:30:04+00:00","author":{"@id":""},"description":"Build your first Electron app! This comprehensive tutorial guides you through creating a","breadcrumb":{"@id":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/developers-heaven.net\/blog\/getting-started-with-electron-your-first-hello-world-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/developers-heaven.net\/blog\/"},{"@type":"ListItem","position":2,"name":"Getting Started with Electron: Your First &#8220;Hello, World&#8221; App"}]},{"@type":"WebSite","@id":"https:\/\/developers-heaven.net\/blog\/#website","url":"https:\/\/developers-heaven.net\/blog\/","name":"Developers Heaven","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/developers-heaven.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/posts\/2075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/comments?post=2075"}],"version-history":[{"count":0,"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/posts\/2075\/revisions"}],"wp:attachment":[{"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/media?parent=2075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/categories?post=2075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers-heaven.net\/blog\/wp-json\/wp\/v2\/tags?post=2075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}