<?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 Kshitij Sawant on Medium]]></title>
        <description><![CDATA[Stories by Kshitij Sawant on Medium]]></description>
        <link>https://medium.com/@sawantkshitij070?source=rss-037697317bb5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ug6gVuinzfuZpnGA</url>
            <title>Stories by Kshitij Sawant on Medium</title>
            <link>https://medium.com/@sawantkshitij070?source=rss-037697317bb5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 19:11:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sawantkshitij070/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[File-Based Routing in React with TanStack Router]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@sawantkshitij070/using-file-based-routing-in-react-with-tanstack-router-3e914573d785?source=rss-037697317bb5------2"><img src="https://cdn-images-1.medium.com/max/1400/0*eM4G3t6cdQRoYC8Z" width="1400"></a></p><p class="medium-feed-snippet">File Based Routing in React Js?</p><p class="medium-feed-link"><a href="https://medium.com/@sawantkshitij070/using-file-based-routing-in-react-with-tanstack-router-3e914573d785?source=rss-037697317bb5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@sawantkshitij070/using-file-based-routing-in-react-with-tanstack-router-3e914573d785?source=rss-037697317bb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e914573d785</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[tanstack]]></category>
            <category><![CDATA[next-js-development]]></category>
            <dc:creator><![CDATA[Kshitij Sawant]]></dc:creator>
            <pubDate>Fri, 17 Jan 2025 03:48:24 GMT</pubDate>
            <atom:updated>2025-06-13T11:30:08.303Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Automating Code Quality with Husky: How to Use Pre-Push Hooks to Improve Your Git Workflow]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Introduction</p><p class="medium-feed-link"><a href="https://medium.com/@sawantkshitij070/automating-code-quality-with-husky-how-to-use-pre-push-hooks-to-improve-your-git-workflow-d53d3ac2339c?source=rss-037697317bb5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@sawantkshitij070/automating-code-quality-with-husky-how-to-use-pre-push-hooks-to-improve-your-git-workflow-d53d3ac2339c?source=rss-037697317bb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d53d3ac2339c</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Kshitij Sawant]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 04:10:02 GMT</pubDate>
            <atom:updated>2025-01-13T04:10:02.795Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Ensuring UI Consistency Across Microfrontends with React and Storybook]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/devxtalks/ensuring-ui-consistency-across-microfrontends-with-react-and-storybook-b2f9586d9345?source=rss-037697317bb5------2"><img src="https://cdn-images-1.medium.com/max/2401/1*F0lFJ2BpED_UFncSO-LHIQ.png" width="2401"></a></p><p class="medium-feed-snippet">Strategies for Component Reuse and Maintaining a Unified User Experience Across Microfrontends Using Storybook and Design Systems</p><p class="medium-feed-link"><a href="https://medium.com/devxtalks/ensuring-ui-consistency-across-microfrontends-with-react-and-storybook-b2f9586d9345?source=rss-037697317bb5------2">Continue reading on DevXtalks »</a></p></div>]]></description>
            <link>https://medium.com/devxtalks/ensuring-ui-consistency-across-microfrontends-with-react-and-storybook-b2f9586d9345?source=rss-037697317bb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2f9586d9345</guid>
            <category><![CDATA[react-microfrontend]]></category>
            <category><![CDATA[storybook-by-react]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[tailwind]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Kshitij Sawant]]></dc:creator>
            <pubDate>Tue, 15 Oct 2024 04:39:46 GMT</pubDate>
            <atom:updated>2024-10-15T04:39:46.396Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Revolutionizing Web Development: The Power of Microfrontends and Module Federation]]></title>
            <link>https://medium.com/devxtalks/revolutionizing-web-development-the-power-of-microfrontends-and-module-federation-945368c5d045?source=rss-037697317bb5------2</link>
            <guid isPermaLink="false">https://medium.com/p/945368c5d045</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[micro]]></category>
            <category><![CDATA[webdeveloper-designer]]></category>
            <dc:creator><![CDATA[Kshitij Sawant]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 07:25:56 GMT</pubDate>
            <atom:updated>2025-05-19T04:51:27.851Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GVNGYkSxJxTuDTJaCbNYrw.gif" /></figure><p>As web applications become more sophisticated, maintaining a single, monolithic codebase can quickly become overwhelming. This complexity often results in slower development, scalability issues, and difficulties in managing dependencies. Microfrontends offer a modern solution by breaking down a large application into smaller, self-contained modules that can be developed and deployed independently. When combined with Module Federation, a powerful tool for sharing and integrating code across applications, developers can create scalable, modular, and efficient web applications.</p><p>In this article, we’ll explore the principles behind Microfrontends and Module Federation, and provide a step-by-step guide to implementing these concepts using React and Vite. Whether you’re aiming to enhance collaboration across teams or simply improve your application’s maintainability, this approach can help you achieve a more robust and flexible frontend architecture.</p><h3>Traditional Approach to Frontend Development: A Legacy System</h3><p>In the traditional approach to frontend development, building a web application typically involves a monolithic architecture where the entire user interface is developed as a single, cohesive unit. This approach means that the frontend codebase is tightly coupled, with different features and components often interdependent on each other. Teams usually work on a large codebase, making it challenging to manage, scale, and deploy changes efficiently.</p><p>Here’s a closer look at some characteristics of the traditional approach:</p><ol><li><strong>Monolithic Structure</strong>: The frontend application is built as a single, unified entity. This can lead to a tightly coupled system where changes to one part of the application might impact others, increasing the risk of bugs and integration issues.</li><li><strong>Centralized Development</strong>: Development is typically handled by a single team or a few teams working on different parts of the application. Coordination is crucial, as any change in one section can affect the entire application, making it difficult to deploy updates independently.</li><li><strong>Scalability Challenges</strong>: Scaling a monolithic frontend can be cumbersome. As the application grows, it becomes more complex and harder to manage. Large codebases can slow down development cycles and make it challenging to implement new features quickly.</li><li><strong>Maintenance Overhead</strong>: Maintaining a monolithic frontend can be demanding. Bug fixes, feature enhancements, and updates require extensive testing across the entire application, increasing the risk of regression issues.</li></ol><p>The traditional approach has served well in the past, but as applications grow more complex and user expectations evolve, there is a growing need for more modular, flexible, and scalable solutions. This is where micro frontends come into play, offering a modern alternative that addresses many of these challenges.</p><h3>What are Microfrontends?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*AKDKqCZgtgq8avYWsJa02g.png" /><figcaption>Monolithic code base vs Microfrontends</figcaption></figure><p>The term “Microfrontend” originates from the concept of microservices, which refers to breaking down a large application into smaller, independently deployable services. Similarly, a microfrontend architecture decomposes a frontend application into smaller, self-contained units that can be developed, tested, and deployed independently by different teams. Think of a microfrontend as a website composed of various web pages, where each page or even sections of a page are created and managed by separate teams.</p><h3>Benefits of Microfrontends</h3><p>There are several key benefits to adopting a microfrontend architecture:</p><ol><li><strong>Independent Deployments</strong>: Microfrontends allow for incremental upgrades and limited deployment scopes. Each microfrontend can have its own CI/CD pipeline, enabling teams to deploy their changes independently without risking issues in other parts of the application.</li><li><strong>Independent Teams</strong>: Teams can own their projects from start to finish, with complete control over their deliverables. Unlike monolithic applications, where teams are often structured based on technical skills (e.g., layout, logic, CSS), microfrontends encourage cross-functional teams that handle all aspects of their specific component.</li><li><strong>Easier Maintenance and Bug Fixes</strong>: Large, monolithic applications can be challenging to maintain and prone to growing complex over time. Microfrontends, by employing a divide-and-conquer strategy, simplify maintenance and make it easier to isolate and fix bugs.</li><li><strong>Tech Stack Freedom</strong>: Microfrontends allow each component to be built with a different tech stack, which can be advantageous for leveraging specific tools and expertise. This also makes it easier to hire developers with specialized skills for different parts of the application.</li></ol><h3>Challenges with Microfrontends</h3><ol><li><strong>Increased Architectural Complexity</strong>: While the modular nature of microfrontends offers significant benefits, it also adds layers of complexity. Managing inter-module communication, shared resources, and ensuring a unified user experience can be difficult. Handling cross-cutting concerns such as authentication, routing, and internationalization requires meticulous planning and can lead to duplicated efforts across different modules.</li><li><strong>State Management Across Microfrontends</strong>: One of the biggest challenges in a microfrontend architecture is managing state across different modules. Since each microfrontend is designed to operate independently, sharing global state or synchronizing data can be difficult. You need to implement strategies like global state management tools or custom APIs to enable seamless data sharing between microfrontends.</li><li><strong>Cross-Microfrontend Communication</strong>: Microfrontends may need to communicate with each other to share data or trigger actions. This inter-module communication can be challenging to implement, as it requires establishing clear contracts and communication protocols between microfrontends, often using events, APIs, or shared services.</li></ol><h3>Introduction to Module Federation</h3><p>As modern web applications grow more complex, the need for scalable architectures increases. Traditional code-sharing methods often lead to bloated bundles, higher maintenance, and dependency management challenges. Module Federation, introduced in Webpack 5, addresses these issues by enabling different applications to dynamically share and load code at runtime, promoting modularity and efficiency.</p><p>This article explores the principles of Module Federation, focusing on its integration with Webpack and its role in enhancing microfrontend architectures. By facilitating dynamic imports and seamless code integration, Module Federation simplifies building scalable and cohesive frontend systems.</p><h3>How Module Federation Works in Webpack ?</h3><p>Module Federation allows applications to share code dynamically at runtime rather than bundling everything upfront during the build process. This is achieved through the ModuleFederationPlugin in Webpack, where you can define which modules an application should expose and which remote modules it should consume from other applications. Each application acts as both a provider and a consumer of modules, enabling a high degree of modularity and code reuse across the system.</p><p>For instance, in a microfrontend architecture, one microfrontend can expose a component that another microfrontend can dynamically import and use. This reduces redundancy and ensures consistency across the application, as shared components can be centrally maintained and updated.</p><h3>Dynamic Imports and Integration with Microfrontends</h3><p>Module Federation’s support for dynamic imports is a game-changer. Instead of loading all code at once, it allows specific modules to be fetched and loaded only when needed, optimizing load times and memory usage while enabling seamless integration between applications.</p><p>In microfrontends, dynamic imports help integrate different application parts without duplicating code. For example, a navigation component created by one team can be dynamically imported and reused by others, ensuring consistency across the app. This approach is invaluable for large-scale applications with multiple teams.</p><p>By leveraging Module Federation, developers gain flexibility, reduce bundle sizes, and simplify building and maintaining complex web applications.</p><h3>How Module Federation Solves Microfrontend Challenges</h3><p>Microfrontends provide flexibility but also introduce challenges like managing shared dependencies, versioning conflicts, and cross-app communication. Module Federation in Webpack 5 addresses these issues, streamlining microfrontend integration.</p><ol><li><strong>Managing Shared Dependencies: </strong>In microfrontend architectures, managing shared dependencies can lead to bloated bundles and version conflicts. Module Federation dynamically shares dependencies between microfrontends, preventing multiple versions of the same library from loading. For instance, if two microfrontends use React, Module Federation ensures only one version is loaded, reducing duplication and optimizing performance.</li><li><strong>Handling Versioning Conflicts: </strong>Versioning conflicts arise when different modules rely on varying library versions. Module Federation resolves this by allowing you to specify which version of a module should be shared or consumed across all microfrontends. This ensures consistency and prevents compatibility issues.</li><li><strong>Simplifying Cross-App Communication: </strong>Microfrontends often need to communicate, but setting up this communication can be complex. Module Federation simplifies it by enabling microfrontends to expose and consume shared modules directly. For example, an authentication service created by one microfrontend can be easily accessed by others, ensuring consistency without duplicate code.</li></ol><p>Module Federation enhances microfrontend architectures by addressing these common challenges, enabling more efficient and cohesive applications.</p><h3>Example: Creating Microfrontends and using Module Federation</h3><p>In this example, we’ll walk through the process of creating a simple microfrontend architecture using Webpack’s Module Federation. We’ll set up two microfrontends: a Host Application and a Remote Application. The Host Application will consume a component exposed by the Remote Application. Here’s how you can set it up:</p><p><strong>Step 1: Set Up the Host Application</strong></p><ol><li><strong>Initialize the Host Application: </strong>Start by creating a new React application for the host:</li></ol><pre>npx create-react-app host-app<br>cd host-app</pre><p>2. <strong>Install Dependencies: </strong>You need to install Webpack and the Module Federation plugin:</p><pre>npm install webpack webpack-cli webpack-dev-server html-webpack-plugin<br>npm install --save-dev @module-federation/webpack</pre><p>3. <strong>Configure Webpack: </strong>Create a ‘webpack.config.js’ file in the root of your ‘host-app’:</p><pre>const HtmlWebpackPlugin = require(&#39;html-webpack-plugin&#39;);<br>const ModuleFederationPlugin = require(&#39;webpack&#39;).container.ModuleFederationPlugin;<br>module.exports = {<br>  mode: &#39;development&#39;,<br>  devServer: {<br>    port: 3000,<br>  },<br>  plugins: [<br>    new ModuleFederationPlugin({<br>      name: &#39;hostApp&#39;,<br>      remotes: {<br>        remoteApp: &#39;remoteApp@http://localhost:3001/remoteEntry.js&#39;,<br>      },<br>    }),<br>    new HtmlWebpackPlugin({<br>      template: &#39;./public/index.html&#39;,<br>    }),<br>  ],<br>};</pre><p>4. <strong>Modify the Host Application: </strong>Replace the content of ‘src/App.js’ to consume the component from the remote application:</p><pre>import React from &#39;react&#39;;<br>const RemoteButton = React.lazy(() =&gt; import(&#39;remoteApp/Button&#39;));<br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Host Application&lt;/h1&gt;<br>      &lt;React.Suspense fallback=&quot;Loading Button...&quot;&gt;<br>        &lt;RemoteButton /&gt;<br>      &lt;/React.Suspense&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default App;</pre><p>5. <strong>Run the Host Application: </strong>Start the development server:</p><pre>npm start</pre><p><strong>Step 2: Set Up the Remote Application</strong></p><ol><li><strong>Initialize the Remote Application: </strong>Create another React application for the remote:</li></ol><pre>npx create-react-app remote-app<br>cd remote-app</pre><p>2. <strong>Install Dependencies: </strong>Similarly, install Webpack and the Module Federation plugin:</p><pre>npm install webpack webpack-cli webpack-dev-server html-webpack-plugin<br>npm install --save-dev @module-federation/webpack</pre><p>3. <strong>Configure Webpack: </strong>Create a ‘webpack.config.js’ file in the root of your ‘remote-app’:</p><pre>const HtmlWebpackPlugin = require(&#39;html-webpack-plugin&#39;);<br>const ModuleFederationPlugin = require(&#39;webpack&#39;).container.ModuleFederationPlugin;<br>module.exports = {<br>  mode: &#39;development&#39;,<br>  devServer: {<br>    port: 3001,<br>  },<br>  plugins: [<br>    new ModuleFederationPlugin({<br>      name: &#39;remoteApp&#39;,<br>      filename: &#39;remoteEntry.js&#39;,<br>      exposes: {<br>        &#39;./Button&#39;: &#39;./src/Button&#39;,<br>      },<br>      shared: { <br>        react: { singleton: true }, <br>        &#39;react-dom&#39;: { singleton: true } <br>      },<br>    }),<br>    new HtmlWebpackPlugin({<br>      template: &#39;./public/index.html&#39;,<br>    }),<br>  ],<br>};</pre><p>4. <strong>Create the Button Component: </strong>In ‘remote-app’, create a new file ‘src/Button.js’:</p><p>4. <strong>Create the Button Component: </strong>In ‘remote-app’, create a new file ‘src/Button.js’:</p><pre>import React from &#39;react&#39;;<br>const Button = () =&gt; {<br>  return (<br>    &lt;button style={{ padding: &#39;10px 20px&#39;, fontSize: &#39;16px&#39; }}&gt;<br>      Click Me from Remote!<br>    &lt;/button&gt;<br>  );<br>};<br>export default Button;</pre><p>5. <strong>Run the Remote Application: </strong>Start the development server:</p><pre>npm start</pre><p><strong>Step 3: Testing the Integration</strong></p><p>With both applications running on different ports, you should now be able to visit ‘<a href="http://localhost:3000/">http://localhost:3000</a>’ (the Host Application) and see the button from the Remote Application rendered on the page. The button component is dynamically imported at runtime from the Remote Application, demonstrating the power of Module Federation in integrating microfrontends.</p><p><strong>Explanation of the Steps</strong></p><ol><li>Webpack Configuration: Both applications have their own Webpack configuration with the ‘ModuleFederationPlugin’. The Host Application is configured to consume remote modules, while the Remote Application exposes specific modules.</li><li>Dynamic Import: In the Host Application, the React.lazy() function is used to dynamically import the Button component from the Remote Application. This lazy loading helps in optimizing the load time by only loading the necessary code when required.</li><li>Shared Dependencies: The shared section in the Webpack configuration ensures that both applications share the same instance of React and ReactDOM, avoiding duplication and potential conflicts.</li><li>Independent Development: The Remote Application can be developed and deployed independently, and any updates to the Button component will be reflected in the Host Application without needing to redeploy the entire host.</li><li>This example illustrates a basic setup for creating and integrating microfrontends using Module Federation. The architecture allows for independent deployment, modular development, and efficient sharing of code across applications.</li></ol><h3>Best Practices for Using Microfrontends and Module Federation</h3><ol><li><strong>Performance Optimization:</strong> To ensure optimal performance, it’s crucial to minimize the number of HTTP requests by carefully managing shared dependencies and using techniques like code splitting. Bundle sizes should be kept small by avoiding duplicate dependencies across microfrontends.</li><li><strong>Consistent User Experience:</strong> Maintain a cohesive user experience by standardizing design systems, UI components, and global state management across all microfrontends. This helps in creating a seamless and unified interface despite the modular nature of the architecture.</li><li><strong>Versioning and Dependency Management:</strong> Use tools like Module Federation to manage versions of shared dependencies and avoid conflicts. This helps in maintaining compatibility and preventing issues caused by mismatched versions of libraries.</li><li><strong>Effective Communication Between Microfrontends:</strong> Establish clear protocols for inter-module communication. Use event buses, shared services, or APIs to manage interactions between different microfrontends without causing tight coupling.</li></ol><p>Implementing these best practices can help you leverage microfrontends and module federation effectively, ensuring a scalable, secure, and user-friendly application.</p><h3>Conclusion</h3><p>Combining microfrontends with module federation offers a powerful approach to building scalable, modular, and maintainable web applications. By breaking down monolithic frontends into independently deployable modules, teams can work more efficiently, reduce deployment risks, and leverage diverse technology stacks. Module federation further enhances this architecture by simplifying the sharing of code and dependencies across different parts of an application, reducing duplication, and ensuring consistency.</p><p>As web development continues to evolve, embracing these technologies can provide a significant edge in creating robust and future-proof applications. I encourage you to explore microfrontends and module federation in your projects to experience firsthand the benefits of a more flexible and scalable frontend architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=945368c5d045" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devxtalks/revolutionizing-web-development-the-power-of-microfrontends-and-module-federation-945368c5d045">Revolutionizing Web Development: The Power of Microfrontends and Module Federation</a> was originally published in <a href="https://medium.com/devxtalks">DevXtalks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>