<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gohilnancy on Medium]]></title>
        <description><![CDATA[Stories by Gohilnancy on Medium]]></description>
        <link>https://medium.com/@gohilnancy09?source=rss-8541fc72d2c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*E86nmKLTkCsYo_DR</url>
            <title>Stories by Gohilnancy on Medium</title>
            <link>https://medium.com/@gohilnancy09?source=rss-8541fc72d2c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:47:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gohilnancy09/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Micro frontends: A Comprehensive Guide]]></title>
            <link>https://medium.com/simform-engineering/understanding-micro-frontends-a-comprehensive-guide-da41c57946ac?source=rss-8541fc72d2c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/da41c57946ac</guid>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[module-federation]]></category>
            <dc:creator><![CDATA[Gohilnancy]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 10:40:18 GMT</pubDate>
            <atom:updated>2024-04-23T10:40:18.881Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Navigating the future: Dive into micro frontend architecture</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bdc2p-gYBW87iUVJhjnOOQ.png" /></figure><p>In the realm of web development, the pursuit of scalable, agile, and maintainable solutions has led to the emergence of innovative architectural paradigms. Micro frontend architecture stands at the forefront of this evolution, offering a revolutionary approach to designing and building frontend applications.</p><p>Traditionally, frontend development involved managing monolithic codebases, where features were tightly coupled within a single application. While functional, this approach posed challenges in scalability, team collaboration, and deployment agility. Micro frontends break down this monolithic structure into smaller, independent pieces, akin to solving a large puzzle.</p><p>At its core, micro frontend architecture lies in the principles of modularity and encapsulation. One of its key advantages is the ability of micro frontends to be developed, tested, deployed, and scaled independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*q1YCa-RD6LTryJHWXmbcYw.png" /><figcaption>Source: cygnismedia</figcaption></figure><h3>Table of content</h3><ul><li><a href="#6611"><strong><em>Pros of Micro frontends</em></strong></a></li><li><a href="#222c"><strong><em>Cons of Micro frontends</em></strong></a></li><li><a href="#c822"><strong><em>Micro frontend vs. monolithic architecture</em></strong></a></li><li><a href="#fcb6"><strong><em>File structure</em></strong></a></li><li><a href="#09cd"><strong><em>Understanding module federation</em></strong></a></li><li><a href="#8b48"><strong><em>Setting up projects</em></strong></a></li><li><a href="#b01f"><strong><em>Conclusion</em></strong></a></li></ul><h3>Pros of Micro frontends</h3><p>The following are some of the advantages of using Micro frontend:</p><ol><li><strong>Independent Development:</strong> Teams can work independently on different application parts, leading to faster development cycles and reduced coordination overhead.</li><li><strong>Scalability:</strong> Micro frontends allow horizontal scaling, enabling teams to scale individual application parts as needed.</li><li><strong>Reusability:</strong> Components and functionality within micro frontends can be reused across different application parts, reducing duplication of effort and maintenance overhead.</li><li><strong>Easier Deployment:</strong> Micro frontend architectures simplify the deployment process by decoupling frontend components from each other, enabling faster time-to-market.</li></ol><h3>Cons of Micro frontends</h3><ol><li><strong>Increased Complexity:</strong> Managing multiple independent frontend applications, each with its own codebase, dependencies, and deployment pipeline, can be challenging and require additional tooling and infrastructure.</li><li><strong>Versioning and Compatibility:</strong> Ensuring that all micro frontends are compatible with each other and the container application requires careful planning and coordination, which can be challenging.</li><li><strong>Cross-Cutting Concerns:</strong> Handling cross-cutting concerns such as authentication, authorization, and routing requires careful planning.</li></ol><h3>Micro frontend vs. Monolithic Architecture</h3><ul><li><strong>Flexibility:</strong> Micro frontend architecture offers more flexibility in technology choices, development processes, and deployment strategies than monolithic architecture.</li><li><strong>Scalability:</strong> Micro frontend architecture enables more granular scaling and resource allocation, improving performance and cost efficiency.</li><li><strong>Complexity:</strong> While offering modularity, micro frontend architecture adds complexity to communication and management.</li><li><strong>Maintenance:</strong> Micro frontend architecture can simplify maintenance and updates by isolating changes to individual micro frontends, but it requires careful coordination and planning to ensure consistency and compatibility across micro frontends.</li><li><strong>Deployment:</strong> Micro frontend architecture allows faster deployments but requires more sophisticated deployment pipelines and tooling to manage multiple independent deployments.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuxX96HM2r0VV8eK7pv0IA.png" /><figcaption>Source: <a href="https://www.trulioo.com/blog/identity-platform/micro-frontends">trulioo.com</a></figcaption></figure><h3><strong>File Structure</strong></h3><p>Here is an example of the file structure of an entire application. It includes a container in which all other micro apps are called, and the other three are the micro apps: header, menu, and cart.</p><pre>my-microfrontend-app/<br>│<br>├── menu/<br>│   ├── src/<br>│   │   ├── components/<br>│   │   │   ├── MenuList.vue<br>│   │   │   <br>│   │   ├── store<br>│   │   ├── App.vue<br>│   │   ├── main.js<br>│   │   └── pubsub.js<br>│   ├── package.json<br>│   └── vite.config.js<br>│<br>├── cart/<br>│   ├── src/<br>│   │   ├── components/<br>│   │   │   ├── Cart.vue<br>│   │   ├── store<br>│   │   ├── App.vue<br>│   │   ├── main.js<br>│   │   └── pubsub.js<br>│   ├── package.json<br>│   └── vite.config.js<br>│<br>├── container/<br>│   ├── src/<br>│   │   ├── components/<br>│   │   │   ├── Home.vue<br>│   │   ├── router<br>│   │   ├── App.vue<br>│   │   ├── main.js<br>│   │   └── pubsub.js<br>│   ├── package.json<br>│   └── vite.config.js<br>│<br>├── header/<br>│   ├── src/<br>│   │   ├── components/<br>│   │   │   ├── Header.vue<br>│   │   ├── App.vue<br>│   │   └── main.js<br>│   ├── package.json<br>│   └── vite.config.js<br>│<br>│<br>└── package.json</pre><p>Info about config and pubsub is explained separately below.</p><h3>Understanding Module Federation</h3><p>Module Federation, introduced in Webpack 5, enables dynamic code sharing between multiple applications at runtime. It enables building micro frontend architectures where multiple frontend applications can be developed, deployed, and maintained independently while sharing common dependencies.</p><p>vite-plugin-federation is a Vite plugin that provides similar functionality to Webpack&#39;s Module Federation but is tailored for use with Vite. It allows us to configure and set up Module Federation in our Vite projects, enabling us to create modular and scalable frontend architectures.</p><p>With vite-plugin-federation, we can define remotes, expose modules, and share dependencies between different Vite applications, allowing for efficient code sharing and dynamic loading of remote modules at runtime.</p><h3>Setup Project</h3><h4><strong>Step 1: Set up the Container Application</strong></h4><ol><li>Create a new directory for the container application:</li></ol><pre>mkdir container-app<br>cd container-app</pre><p>2. Initialize a new Vite project for the container application:</p><pre>npm init @vitejs/app</pre><p>3. When prompted, choose “vue” or any other technology as the project template.</p><p>4. Install vite-plugin-federation and vue-router:</p><pre>npm install vite-plugin-federation vue-router</pre><p>5. Create a vite.config.js file at the root of the project:</p><pre>// vite.config.js<br>import { defineConfig } from &#39;vite&#39;;<br>import Vue from &#39;@vitejs/plugin-vue&#39;;<br>import federation from &#39;vite-plugin-federation&#39;;</pre><pre>export default defineConfig({<br>  plugins: [<br>    Vue(),<br>    federation({<br>      name: &#39;container&#39;,<br>      remotes: {<br>        &#39;cart&#39;: &#39;http://localhost:3001/dist/assets/cart.js&#39;,<br>        &#39;menu&#39;: &#39;http://localhost:3002/dist/assets/menu.js&#39;,<br>        &#39;header&#39;: &#39;http://localhost:3003/dist/assets/header.js&#39;,<br>      },<br>    }),<br>  ],<br>});</pre><p>In the above code, a build is created in all the applications using npm run build, and after that, a dist folder is created in each app. We have to use the path of each dist folder with the URL of each application to integrate all apps together. This can be done similarly for any framework, whether vuejs, reactjs, or angular.</p><h4><strong>Step 2: Set up the Micro frontend Applications (Menu, Cart, Header)</strong></h4><p>For each micro frontend application (<strong>Menu, Cart, Header</strong>), repeat the following steps:</p><ol><li>Create a new directory for the micro frontend:</li></ol><pre>mkdir cart<br>cd cart</pre><p>2. Initialize a new Vite project for the micro frontend:</p><pre>npm init @vitejs/app</pre><p>3. Choose “vue” as the project template when prompted.</p><p>4. Install vite-plugin-federation:</p><pre>npm install vite-plugin-federation</pre><p>5. Create a vite.config.js file at the root of the cart app:</p><pre>// vite.config.js<br>import { defineConfig } from &#39;vite&#39;;<br>import federation from &#39;vite-plugin-federation&#39;;</pre><pre>export default defineConfig({<br>  plugins: [<br>    federation({<br>      name: &#39;cart&#39;,<br>      filename: &#39;cart.js&#39;,<br>      exposes: {<br>        &#39;./App&#39;: &#39;./src/App.vue&#39;,<br>      },<br>    }),<br>  ],<br>});</pre><p>Repeat this step for the Header and Menu App with the files that have to be exposed to other apps.</p><p>vite.config.js file at the root of the Container app:</p><pre>// vite.config.js<br>import { defineConfig } from &#39;vite&#39;;<br>import federation from &#39;vite-plugin-federation&#39;;</pre><pre>export default defineConfig({<br>  plugins: [<br>    federation({<br>      name: &#39;container&#39;,<br>      filename: &#39;container.js&#39;,<br>      remotes: {<br>        &#39;cart&#39;: &#39;http://localhost:3001/cart.js&#39;,<br>        // Add more remotes as needed<br>      },<br>      exposes: {<br>        &#39;./App&#39;: &#39;./src/App.vue&#39;,<br>      },<br>    }),<br>  ],<br>});</pre><p>Repeat this step for the Header and Menu Apps, changing the port number and remote name accordingly. The remote name should be similar to the individual file name mentioned in each app&#39;s config file.</p><p><strong>Exposes</strong>: Exposing a module means making it available for consumption by other micro frontends. When a micro frontend exposes a module, it declares certain components, utilities, or functionalities available for use by other micro frontends.</p><p><strong>Remote</strong>: Remoting a module means importing and using modules that are exposed by other micro frontends. When a micro frontend remotely imports a module, it retrieves and uses components, utilities, or functionalities exposed by other micro frontends.</p><h4>Step 3: Run the Applications</h4><ol><li>Start each micro frontend application (Header, Cart, Menu):</li></ol><pre>cd header <br>npm run dev</pre><p>Repeat for Cart and Menu.</p><p>2. Start the container application:</p><pre>cd container<br>npm run dev</pre><h4>Inter-App Communication</h4><p>To communicate between the apps, there needs to be a trigger event so that while passing data from one app to another, apps know when the data is passed. Publish/Subscribe is the best way for the event to trigger between apps. Follow the same as below:</p><p>Create a pubsub.js in src folder of all apps. The js file can be named at your convenience.</p><pre>// src/pubsub.js<br>const globalListenersKey = &#39;__pubsub_listeners__&#39;;</pre><pre>const getGlobalListeners = () =&gt; {<br>  if (!window[globalListenersKey]) {<br>    window[globalListenersKey] = {};<br>  }<br>  return window[globalListenersKey];<br>};</pre><pre>export const pubsub = {<br>  subscribe: (event, callback) =&gt; {<br>    const listeners = getGlobalListeners();</pre><pre>if (!listeners[event]) {<br>      listeners[event] = [];<br>    }<br>    listeners[event].push(callback);<br>  },<br>  publish: (event, data) =&gt; {<br>    const listeners = getGlobalListeners();</pre><pre>if (listeners[event]) {<br>      listeners[event].forEach((callback) =&gt; callback(data));<br>    }<br>  },<br>};</pre><ol><li>globalListenersKey: This variable defines a unique key to store the global listeners in the window object. This key is used to access the global listeners object.</li><li>getGlobalListeners: This function retrieves the global listeners object from the window object. If the listeners object does not exist yet, it takes an empty object as default.</li><li>pubsub object: This object contains two methods:</li></ol><ul><li>subscribe: This method is used to subscribe to a specific event. It takes two parameters: event (the name of the event to subscribe to) and callback (the function to be called when the event is published.) It retrieves the global listeners object, creates an array for the specified event if it doesn&#39;t exist yet, and adds the provided callback function to that array.</li><li>publish: This method is used to publish a message to all subscribers of a specific event. It takes two parameters: event (the name of the event to publish) and data (the data to be passed to the subscribers). It retrieves the global listeners object, checks for subscribers for the specified event, and, if so, iterates over the array of callbacks for that event, calling each callback function with the provided data.</li></ul><p>Let’s see how we can call the publish and subscribe method with an example in which we will publish a method in the Menu app and subscribe in the container app:</p><pre>//Menu app<br>pubsub.publish(&quot;addToCart&quot;, data);</pre><pre>//container app<br>pubsub.subscribe(&quot;addToCart&quot;, (product) =&gt; {<br>console.log(product)<br>});</pre><h3>Conclusion</h3><p>Embracing micro frontend architecture revolutionizes development, enabling agility, scalability, and rich user experiences. With flexibility and collaboration, micro frontends pave the way for the future of web development.</p><p>Micro frontend is an amazing architecture for complex projects and teams, but it requires careful consideration of its drawbacks. Your evaluation and strategic implementation will lead to a successful journey. Enjoyed the read? Reach out with any questions!</p><p><strong><em>Implementation demo: </em></strong><a href="https://github.com/Nancyy0912/Vue-Microfrontend-Demo"><strong>github.com/<em>Nancyy0912/Vue-Microfrontend-Demo</em></strong></a></p><blockquote><strong><em>For more updates on the latest tools and technologies, follow the </em></strong><a href="https://medium.com/simform-engineering"><strong><em>Simform Engineering</em></strong></a><strong><em> blog.</em></strong></blockquote><blockquote><strong><em>Follow us: </em></strong><a href="https://twitter.com/simform"><strong><em>Twitter</em></strong></a><strong><em> | </em></strong><a href="https://www.linkedin.com/company/simform/"><strong><em>LinkedIn</em></strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da41c57946ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/understanding-micro-frontends-a-comprehensive-guide-da41c57946ac">Understanding Micro frontends: A Comprehensive Guide</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Cross-Platform Desktop Apps with Electron, Vite, Vue 3, and Electron Builder]]></title>
            <link>https://medium.com/simform-engineering/building-cross-platform-desktop-apps-with-electron-vite-vue-3-and-electron-builder-724598092a92?source=rss-8541fc72d2c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/724598092a92</guid>
            <category><![CDATA[electronjs]]></category>
            <category><![CDATA[chromium]]></category>
            <category><![CDATA[ipc]]></category>
            <category><![CDATA[cross-platform-apps]]></category>
            <category><![CDATA[electron-builder]]></category>
            <dc:creator><![CDATA[Gohilnancy]]></dc:creator>
            <pubDate>Mon, 30 Oct 2023 11:53:36 GMT</pubDate>
            <atom:updated>2023-10-30T11:53:36.703Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An easy guide to crafting versatile desktop applications with Electron.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-z0Vqi10vxJTexusyFSDg.png" /></figure><p>Today, the boundary between web and desktop applications is becoming increasingly blurred. With the emergence of technologies like Electron, Vite, and Vue 3, you can use the power of both web and desktop development to create feature-rich and visually appealing cross-platform desktop applications.</p><p>In this blog post, we will guide you through the process of building a desktop app using the dynamic combination of Electron, Vite, Vue 3, and Electron Builder. This will enable you to create, develop, and package desktop applications that run seamlessly on Windows, macOS, and Linux.</p><h3>What You Need to Know</h3><ul><li><strong>Electron</strong>: It’s an open-source framework that lets you create desktop applications using web technologies. Electron is based on <a href="https://nodejs.org/">Node.js</a> and <a href="https://www.chromium.org/">Chromium</a>. Examples of applications built with Electron include the <a href="https://github.com/atom/atom">popular Atom editor</a>, Visual Studio Code, WordPress for desktop, and Slack. Behind the scenes, Electron combines the Chromium engine with Node.js runtime to read and run your codebase as a standalone desktop program.</li><li><strong>Vite</strong>: It’s a build tool and development server that accelerates the development process by leveraging ES modules. It aims to provide a faster and leaner development experience for modern web projects.</li><li><strong>Vue 3</strong>: The latest version of Vue.js, Vue 3, is known for its simplicity and reactivity.</li><li><strong>Electron Builder</strong>: Electron Builder is a robust tool that simplifies packaging and distributing Electron applications. It supports creating installer packages for various platforms, streamlining the deployment process.</li></ul><h4><a href="https://coolsymbol.com/copy/Page_Facing_Up_Emoji_Symbol_%F0%9F%93%84">📄</a> Table of content</h4><ul><li><strong><em>Prerequisites</em></strong></li><li><strong><em>Pros of using Electron</em></strong></li><li><strong><em>Cons of using Electron</em></strong></li><li><strong><em>Setup Project</em></strong></li><li><strong><em>What is IPC?</em></strong></li><li><strong><em>Conclusion</em></strong></li></ul><h4><strong>Prerequisites</strong></h4><p>Before we get started, make sure you have the following installed on your machine:</p><ul><li><a href="https://nodejs.org/">Node.js</a></li><li><a href="https://www.npmjs.com/">npm</a> (Node Package Manager)</li></ul><h4><strong>Pros</strong></h4><p>The following are some of the advantages of using Electron:</p><ul><li>Single codebase — With Electron, you’ll only need one codebase to create desktop applications for different operating systems.</li><li>Leverage web skills — If you have prior experience working with basic web stacks (HTML, CSS, and JavaScript), it is super easy to get started with Electron.</li><li>Big community — The Electron community is quite a big and active one, largely because the framework is being used and supported by top companies across the globe.</li></ul><h4><strong>Cons</strong></h4><p>The following are some of the disadvantages of using Electron:</p><ul><li>Higher resource consumption — Desktop applications written in Electron consume more CPU and RAM compared to apps written in other environments, such as Java FX, Objective C, and so on</li><li>Larger app size — As previously stated, Electron applications bundle the Chromium engine during the build process, which results in a big app size even for a simple application.</li></ul><h3>Setting Up the Project</h3><p>Let’s create a new Electron.js project with Vue 3.</p><h4>1. Installing Vite</h4><p>We’ll start by installing Vite globally. Open your terminal and run the following command:</p><pre>npm install -g create-vite</pre><h4>2. Creating a Vite Project</h4><p>Now, let’s create a new Vite project. Navigate to your desired project directory in the terminal and execute the following command:</p><pre>create-vite my-electron-vue-app</pre><h4>3. Installing Dependencies</h4><p>Enter your project directory:</p><pre>cd my-electron-vue-app</pre><p>Install Electron and Electron Builder as dependencies:</p><pre>npm install electron electron-builder --save-dev</pre><h4>4. Project Structure</h4><p>In your project directory, you’ll find a structure like this:</p><ul><li>src: This is where you&#39;ll create your Vue components.</li><li>public: Place your static assets here.</li></ul><h4>File Structure:</h4><p>The file structure will remain identical to a Vue project generated by Vue CLI, except for the “main.js” file.</p><p>In this file, you can configure the default width and height of the window the application launches with, set the application title, and add an auto-update feature, among other things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*XgvmcCup3USOvVFS7BPKqQ.png" /></figure><h4>5. Vue Development Server</h4><p>Start the Vite development server:</p><pre>npm run dev</pre><p>This will provide a local development server that you can access at <a href="http://localhost:3000.">http://localhost:3000.</a></p><h4>6. Creating the Main Electron File</h4><p>Now, let’s create the entry point for your Electron app. In the project root directory, create a file named main.js. This file will define the Electron application&#39;s main process:</p><pre>const { app, BrowserWindow } = require(&#39;electron&#39;);</pre><pre>let mainWindow;</pre><pre>app.whenReady().then(() =&gt; {<br>  mainWindow = new BrowserWindow({<br>    width: 800,<br>    height: 600,<br>    webPreferences: {<br>      nodeIntegration: true,<br>    },<br>  });</pre><pre>  mainWindow.loadURL(&#39;http://localhost:3000&#39;);<br>});</pre><p>This code initializes an Electron app and creates a window that loads your Vue application running on localhost:3000.</p><h4>7. Vue Components</h4><p>In the src directory, you can create your Vue components as you would in a standard Vue project.</p><h4>8. Electron Integration</h4><p>To access Electron APIs from your Vue components, you can use the window.require syntax. For example:</p><pre>const { ipcRenderer } = window.require(&#39;electron&#39;);</pre><h3>Building and Packaging Your Electron App</h3><p>With your Vue app and Electron setup in place, it’s time to build and package your Electron app for distribution.</p><h4>1. Building the Vue App</h4><p>Build your Vue app:</p><pre>npm run build</pre><p>This command generates a production-ready build of your Vue application in the dist directory.</p><h4>2. Updating the Main Electron File</h4><p>In the main.js file, update the line that loads your app to point to the built Vue app:</p><pre>mainWindow.loadFile(&#39;dist/index.html&#39;);</pre><h4>3. Electron Builder Configuration</h4><p>To configure Electron Builder, create a electron-builder.yml file in your project root. This file specifies the build targets and settings for your application. Here&#39;s a basic example:</p><pre>targets:<br>  - target: nsis<br>    arch: x64</pre><p>This configuration instructs Electron Builder to build an installer package for Windows (NSIS) targeting the x64 architecture.</p><h4>4. Packaging Your App</h4><p>Now, you’re ready to package your Electron app for distribution. Run the following command:</p><pre>npx electron-builder</pre><p>Electron Builder will package your app according to your configuration settings and generate installer packages for your target platforms.</p><p>The output would resemble the one shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*K1I8RFVnHoeOVyVjhTxbtg.png" /></figure><p>You can also close the Devtools if needed, as it comes by default.</p><p>On closing Devtools, it will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*ezRldRk2kLPkBWRD948NqQ.png" /></figure><h3>What is IPC?</h3><p>In Electron.js, Inter-Process Communication (IPC) is a mechanism that allows different processes in your Electron application to communicate with each other. The primary use cases for IPC are communication between the main process and renderer processes (web pages) or between different renderer processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*zUWDJzloD7VTinbQS-9gSQ.png" /><figcaption>Image Credit: <a href="https://insujang.github.io/2019-11-10/code-server/">insujang</a></figcaption></figure><h3>Sending Messages from Renderer Process to Main Process</h3><p>To send a message from the renderer process (your web page) to the main process, you can use ipcRenderer.send():</p><pre>const { ipcRenderer } = require(&#39;electron&#39;);</pre><pre>// Send a message to the main process<br><br>ipcRenderer.send(&#39;message-channel&#39;, &#39;Hello from renderer process!&#39;);</pre><p>In the example above, we import ipcRenderer from the &#39;electron&#39; module and use ipcRenderer.send() to send a message with the channel name &#39;message-channel&#39; and a message payload.</p><h4>Receiving Messages in the Main Process</h4><p>In the main process, you need to listen for messages on the same channel using the ipcMain module. Typically, this is done in the main script (main.js) of your Electron application:</p><pre>const { app, BrowserWindow, ipcMain } = require(&#39;electron&#39;);</pre><pre>let mainWindow;<br><br>app.whenReady().then(() =&gt; {<br>  mainWindow = new BrowserWindow({<br>    width: 800,<br>    height: 600,<br>  });<br><br>  mainWindow.loadFile(&#39;index.html&#39;);<br><br>  // Listen for messages from renderer process<br>  ipcMain.on(&#39;message-channel&#39;, (event, message) =&gt; {<br>    console.log(&#39;Received message in main process:&#39;, message);<br>  });<br>});</pre><p>Here, we use ipcMain.on() to listen for messages on the &#39;message-channel&#39;. When a message is received, we log it to the console.</p><h3>Sending Messages from the Main Process to the Renderer Process</h3><p>To send a message from the main process to the renderer process, you can use webContents.send() on the BrowserWindow instance representing the renderer process:</p><pre>const { ipcMain } = require(&#39;electron&#39;);</pre><pre>// Send a message to the renderer process<br>ipcMain.on(&#39;send-to-renderer&#39;, (event) =&gt; {<br>  event.sender.send(&#39;message-channel&#39;, &#39;Hello from main process!&#39;);<br>});</pre><p>In this example, when the main process receives a message on the ‘send-to-renderer’ channel, it sends a response message to the renderer process using event.sender.send().</p><h3>Receiving Messages in the Renderer Process</h3><p>In the renderer process, you can listen for messages sent from the main process using ipcRenderer.on():</p><pre>const { ipcRenderer } = require(&#39;electron&#39;);</pre><pre>// Listen for messages from main process<br>ipcRenderer.on(&#39;message-channel&#39;, (event, message) =&gt; {<br>  console.log(&#39;Received message in renderer process:&#39;, message);<br>});</pre><p>Here, we use ipcRenderer.on() to listen for messages on the &#39;message-channel&#39; in the renderer process. When a message is received, we log it to the console.</p><p>These are the basics of using ipcRenderer in Electron to enable communication between the renderer process (front-end) and the main process (back-end) of your Electron application. This mechanism is crucial for building interactive and responsive desktop applications using Electron.</p><p><strong>Reference:</strong></p><p><a href="https://www.electronjs.org/docs/latest/">https://www.electronjs.org/docs/latest</a></p><h4>Conclusion</h4><p>Combining Electron, Vite, Vue 3, and Electron Builder empowers you to create cross-platform desktop applications with the ease and familiarity of web development. Whether you’re building productivity tools, creative applications, or utilities, this tech stack provides the versatility to bring your ideas to life on the desktop.</p><p>As you begin to develop desktop applications this way, explore the rich documentation of these technologies to harness their full potential. The world of cross-platform desktop development is at your fingertips, and your creativity is the only limit to what you can achieve. Start building amazing desktop apps today!</p><blockquote><strong>For more updates on the latest tools and technologies, follow the </strong><a href="https://medium.com/simform-engineering"><strong>Simform Engineering</strong></a><strong> blog.</strong></blockquote><blockquote><strong>Follow Us: </strong><a href="https://twitter.com/simform"><strong>Twitter</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/simform/"><strong>LinkedIn</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=724598092a92" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/building-cross-platform-desktop-apps-with-electron-vite-vue-3-and-electron-builder-724598092a92">Building Cross-Platform Desktop Apps with Electron, Vite, Vue 3, and Electron Builder</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>