<?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 Prateek Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Prateek Srivastava on Medium]]></description>
        <link>https://medium.com/@prateeks910?source=rss-697710f16ec0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Xf0OsadpgbpBaCYpjsf6XQ.jpeg</url>
            <title>Stories by Prateek Srivastava on Medium</title>
            <link>https://medium.com/@prateeks910?source=rss-697710f16ec0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 12:46:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prateeks910/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[I’m curious about Micro Frontend. What is it?]]></title>
            <link>https://medium.com/@prateeks910/im-curious-about-micro-frontend-what-is-it-d0a8f22d0bd2?source=rss-697710f16ec0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0a8f22d0bd2</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[micro-front-end]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[module-federation]]></category>
            <category><![CDATA[implement-microfrontend]]></category>
            <dc:creator><![CDATA[Prateek Srivastava]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 15:39:35 GMT</pubDate>
            <atom:updated>2025-01-19T15:39:35.935Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Micro frontend</strong> is an architectural style in which a web application is broken down into smaller, independently developed, and deployed front-end applications (“micro-apps”). These micro-apps can use different technologies and seamlessly integrate into a unified user experience. This approach mirrors the microservices architecture used on the backend.</p><figure><img alt="App Composition using Micro Frontends" src="https://cdn-images-1.medium.com/max/1024/1*E62f4gYPYIAiLHSi9Xg1yA.png" /><figcaption>App Composition using Micro Frontends</figcaption></figure><p><strong>Why did the need arise for Micro frontend?</strong></p><ul><li>In monolithic applications, multiple teams often work on the same codebase, which leads to merge conflicts, dependency management issues, and bottlenecks in deployment.</li><li>As frontend applications grow in size and complexity, maintaining a single monolithic codebase becomes hard, often resulting in technical debt over time.</li><li>In monolithic frontends, deploying a small feature requires rebuilding and redeploying the entire application, which is time-consuming and risky.</li><li>Monolithic frontends often lock teams into a single framework or technology stack, making it hard to adopt newer technologies.</li><li>Modernizing a monolithic application would require a complete rewrite, which would be time-consuming and expensive.</li></ul><p><em>Ok. How do we go about it then?</em></p><p><strong>Common Implementation Patterns:</strong></p><ol><li><strong>Web Components:</strong><br>Web Components allow you to create reusable custom elements that can be easily used across all popular JavaScript frameworks and libraries.</li></ol><figure><img alt="Web Components in action" src="https://cdn-images-1.medium.com/max/1024/1*3UQptwOMyUmmlhmT_XBDNA.png" /><figcaption>Web Components in action</figcaption></figure><p><em>Here is a working example </em><a href="https://stackblitz.com/edit/vitejs-vite-4ebe5ieq?file=src%2FApp.jsx">https://stackblitz.com/edit/vitejs-vite-4ebe5ieq?file=src%2FApp.jsx</a></p><p>Web Component Advantages and Use Cases:</p><ul><li>Since all javascript libraries and frameworks support web components, they present a good use case for building framework-agnostic design libraries</li><li>Web components use Shadow DOM, so they are a good fit for widgets that can be integrated into external websites.</li><li>Shadow DOM usage also makes them a good fit for being used as browser extensions as we won’t have to worry about the host website’s code or styles.</li></ul><p>While web components are great, they have their limitations</p><ul><li><strong>Learning Curve</strong>: Not all developers may be familiar with web components, so training and additional effort are required to onboard teams.</li><li><strong>Integration Complexity</strong>: While web components are framework-agnostic, integrating them with frameworks like React, Angular, or Vue can sometimes require workarounds.</li><li><strong>Debugging Challenges</strong>: Debugging web components can be harder due to the encapsulation of the Shadow DOM, making it less straightforward to inspect DOM and styles.</li><li><strong>Performance Issues with Shadow DOM</strong>: If too many web components with Shadow DOM are used, rendering performance can degrade on certain devices or browsers.</li><li><strong>Polyfills</strong>: Older browsers may require polyfills for web component features (e.g., Shadow DOM, Custom Elements), increasing the bundle size and load time.</li><li><strong>Hydration Issues</strong>: If server-side rendering (SSR) is used, web components can introduce hydration issues as they are client-side-rendered.</li><li><strong>Accessibility</strong>: Ensuring web components are accessible requires extra effort, as the Shadow DOM may block inherited accessibility features.</li><li><strong>Cross-Origin Issues</strong>: If web components load resources (e.g., images, styles) from other origins, they may introduce CORS-related challenges.</li><li><strong>Theming</strong>: Due to style isolation, it can be challenging to apply consistent theming (e.g., CSS variables, global styles) across multiple web components.</li></ul><p>You can read more about web components on the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components">MDN site</a></p><p>2. <strong>Iframes</strong></p><p>Iframes are HTML elements that load other HTML pages into your web pages. This is the oldest style of micro frontend implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*LiRkfgzFLxDeD89c4meYWw.png" /><figcaption>Web Application composition using iframes</figcaption></figure><p>Host application embeds micro frontends using iframes. Host and micro-frontends communicate (if needed) using mechanisms like <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage">postMessage</a></p><p><em>Here is an example of embedding a YouTube video via iframe</em> <a href="https://www.w3schools.com/html/tryit.asp?filename=tryhtml_youtubeiframe_autoplay">https://www.w3schools.com/html/tryit.asp?filename=tryhtml_youtubeiframe_autoplay</a></p><p>Iframes Advantages and Use Cases:</p><ul><li><strong>Complete Isolation</strong>: Each iframe is a fully isolated environment, with its own JavaScript scope, CSS, and global objects. Crashes or errors in one iframe do not impact the rest of the application, improving reliability. Also, the isolation prevents direct manipulation of the host application or other micro frontends, offering strong protection against unintended side effects.</li><li><strong>Technology Agnostic</strong>: Each micro frontend can use its tech stack without conflicting with others.</li><li><strong>Independent Deployment</strong>: Each micro frontend is a standalone app that can be deployed independently on its domain or subdomain.</li><li><strong>Legacy Support</strong>: Integrating legacy systems or older applications is easier as iframes can load any URL.</li></ul><p>Iframe Limitations:</p><ul><li><strong>Performance Issues</strong>: Iframes can have slower initial load times due to isolated browser environments.</li><li><strong>Communication Complexity</strong>: Communication between the host and micro-frontends requires explicit handling using postMessage or other APIs, which can be complex to manage and debug.</li><li><strong>SEO Limitations</strong>: Search engines do not index content inside iframes, potentially harming SEO.</li><li><strong>Accessibility Concerns</strong>: Iframes can create challenges for screen readers and other assistive technologies, reducing accessibility.</li><li><strong>Cross-Origin Restrictions</strong>: Strict CORS policies can complicate interactions between the host and micro-frontends when hosted on different domains.</li></ul><p>For further details about iframes, you can refer to the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe">MDN site</a></p><p>3. <strong>Module Federation</strong></p><p>Module Federation is a feature introduced in Webpack 5 that allows JavaScript applications to share code and dependencies dynamically at runtime, enabling seamless integration between multiple applications.</p><p>Webpack generates a special runtime that enables the host application to discover and load exposed modules from the remote application as a js bundle.</p><figure><img alt="Loading Remote Content via Module Federation" src="https://cdn-images-1.medium.com/max/1024/1*WPNQL_MNStSeW-YAjc34FA.png" /><figcaption>Loading Remote Content via Module Federation</figcaption></figure><p>Other bundlers like Vite and Rollup have similar approaches available as well.</p><p><em>I’ve set a repo for you to see module federation in action</em> <a href="https://github.com/Prateeks91/module-federation-example">https://github.com/Prateeks91/module-federation-example</a></p><p>Module Federation advantages:</p><ul><li><strong>Dynamic Loading</strong>: Only loads what is required. Host applications can choose to load remotes lazily.</li><li><strong>Independent Deployments</strong>: Updates in remote apps do not require rebuilding the host.</li><li><strong>Shared Dependencies</strong>: Avoids duplicate dependencies. When the host application requests a module from the remote, it first checks if the shared dependency (e.g., react) is already loaded in the host. If it exists and satisfies the required version, the host reuses its instance instead of downloading a duplicate from the remote(However, this behavior can be overridden)</li></ul><p>Module Federation limitations:</p><ul><li><strong>Initial Setup</strong>: Requires coordination between host and remote apps. Unlike iframes, onboarding an existing running web application is not easy, as the host and remote both are to be configured</li><li><strong>Runtime Errors</strong>: Version mismatches in shared libraries may cause runtime issues.</li></ul><p>Details are available on the official <a href="https://webpack.js.org/concepts/module-federation/">Webpack site</a>.</p><p>4. <strong>Client-Side Composition</strong></p><p>Client-side composition involves dynamically loading and integrating micro-frontends into a single browser application. The integration happens entirely on the client side at runtime.</p><p>Each micro-frontend is exposed as a standalone application (usually a set of JavaScript bundles).</p><p>A framework like <strong>Single-SPA</strong> or custom logic dynamically imports these micro-frontends into the main application.</p><p>The main application or a shared router handles routing between micro-frontends.</p><p>Unlike module federation, where integration is managed by web pack, here the shell application manages the integration at runtime.</p><figure><img alt="Client Side Composition(on routes) with React, Angular and Vue" src="https://cdn-images-1.medium.com/max/1024/1*G9D5G3zGS25UKyo872S1Ag.png" /><figcaption>Client Side Composition(on routes) with React, Angular and Vue</figcaption></figure><p>Here is a repo that shows usage of Angular, Vue, and React in one single application using Single SPA <a href="https://github.com/nitinreddy3/react-ng-spa-app">https://github.com/nitinreddy3/react-ng-spa-app</a></p><p>Client -Side Composition advantages:</p><ul><li><strong>Improved Scalability: </strong>Individual teams can develop, deploy, and manage their micro-frontends independently.</li><li><strong>Flexibility in Technology: </strong>Teams can use different frameworks and libraries. Also, eases the adoption of new technologies.</li></ul><p>Client -Side Composition challenges:</p><ul><li><strong>Performance Overhead: </strong>Increased initial load time due to fetching multiple micro-frontends from different sources. Latency issues may arise if micro-frontends are hosted on geographically distant servers.</li><li><strong>Complexity in Dependency Management and Integration: </strong>Sharing dependencies (e.g., React, Angular) between micro-frontends requires careful configuration to avoid version mismatches and redundancy. Integrating micro-frontends in the browser can lead to issues with event management, global state sharing, or CSS conflicts.</li><li><strong>SEO Limitations: </strong>SEO can be negatively impacted because much of the application is rendered dynamically in the browser.</li><li><strong>Cross-Team Communication Overhead: </strong>Collaboration among teams is crucial to ensure consistent styles, UI components, and shared resources.</li></ul><p>Single SPA is a popular framework that implements this pattern. More details can be read on the <a href="https://single-spa.js.org/">Single SPA site</a></p><p>5.<strong> Server-Side Composition</strong></p><p>Server-side composition in micro frontends refers to assembling multiple independent frontend components into a single server response, before sending it to the client. Instead of letting the client (browser) perform the composition, the server combines the various micro frontends (usually deployed as separate services or apps) into a unified page. This is done through server-side technologies like Node.js, Express, or a server-side rendering (SSR) setup in a framework like Next.js or Nuxt.js.</p><figure><img alt="Web Application Rendering Using Server Side Composition" src="https://cdn-images-1.medium.com/max/712/1*d4LCyIwDFnZIKYaMOo1EiQ.png" /><figcaption>Web Application Rendering Using Server Side Composition</figcaption></figure><p><em>Refer to this repo to see this approach in action</em> <a href="https://github.com/Prateeks91/server-side-composition-example">https://github.com/Prateeks91/server-side-composition-example</a></p><p>Server -Side Composition advantages:</p><ul><li><strong>SEO-Friendly</strong>: Since the server sends a fully composed page to the client, search engines can easily index the content, improving SEO performance.</li><li><strong>Faster Initial Load</strong>: As the content is pre-assembled on the server, the initial page load can be faster, as the client doesn’t need to make multiple requests for different micro frontends.</li></ul><p>Server -Side Composition challenges:</p><ul><li><strong>Complex Server-Side Logic</strong>: The server-side composition logic can become complex as the number of micro frontends increases. It may involve handling different frameworks, managing versions, and integrating various services.</li><li><strong>Performance Bottleneck</strong>: The server has to assemble all the components before sending the response, potentially adding overhead, especially with a large number of micro frontends.</li></ul><p>While implementing micro frontends may require significant upfront planning and infrastructure changes, the benefits in terms of scalability, maintainability, and team autonomy can outweigh the initial challenges. By embracing micro frontends, you set your project up for long-term success in an ever-evolving web development landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0a8f22d0bd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>