<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ratan Singh</title>
    <description>The latest articles on DEV Community by Ratan Singh (@i_m_ratan).</description>
    <link>https://dev.to/i_m_ratan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2001486%2F61a32577-431a-47a7-80f1-c888778827e1.jpg</url>
      <title>DEV Community: Ratan Singh</title>
      <link>https://dev.to/i_m_ratan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/i_m_ratan"/>
    <language>en</language>
    <item>
      <title>Introduction to Micro-frontend</title>
      <dc:creator>Ratan Singh</dc:creator>
      <pubDate>Fri, 30 Aug 2024 06:56:29 +0000</pubDate>
      <link>https://dev.to/i_m_ratan/introduction-to-micro-frontend-11ln</link>
      <guid>https://dev.to/i_m_ratan/introduction-to-micro-frontend-11ln</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;In Micro-frontend we divide a monolithic app into multiple smaller apps.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Each app is responsible for distinct feature of the monolithic app.&lt;br&gt;
For example,&lt;br&gt;
An E-Commerce app can be divided into below smaller independent micro frontend apps.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Products Listing&lt;/li&gt;
&lt;li&gt;Cart&lt;/li&gt;
&lt;li&gt;Shipping&lt;/li&gt;
&lt;li&gt;Payment&lt;/li&gt;
&lt;li&gt;Tracking&lt;/li&gt;
&lt;li&gt;Customer Services etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Micro-frontend?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Multiple teams can work in isolation dedicated to one MFE app.&lt;/li&gt;
&lt;li&gt;Code reusability is very high.&lt;/li&gt;
&lt;li&gt;Each team is free to choose their own technology (React/Angular/Vue), deployment, development strategies etc.&lt;/li&gt;
&lt;li&gt;If one app is down, rest apps can still work.&lt;/li&gt;
&lt;li&gt;Each MFE app is smaller so easy to understand and make changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Monolithic Vs Micro frontend App Architecture&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frioyqjj14avd6ieb5tch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frioyqjj14avd6ieb5tch.png" alt="micro frontend architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Monolithic App :-&lt;/strong&gt; All features of web-application in a single app.&lt;br&gt;
&lt;strong&gt;Micro-frontend App :-&lt;/strong&gt; Each feature is managed by an independent MFE app i.e.&lt;br&gt;
MFE #1 is responsible for App-bar.&lt;br&gt;
MFE #2 is responsible for Products-List.&lt;br&gt;
MFE #3 is responsible for Side-Nav bar.&lt;br&gt;
Container App is responsible for coordinating between these MFE apps.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How MFE apps integrates with each other&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Build Time integration (Compile Time integration)&lt;/li&gt;
&lt;li&gt;Run Time integration (Client side integration)&lt;/li&gt;
&lt;li&gt;Server Side integration (SSR integration).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Build Time integration (Compile Time integration)&lt;/strong&gt;&lt;br&gt;
In this integration, container app has access to all MFE apps source code and a combined bundle is created when Container app is build / compiled before loading in browser.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very simple to setup and understand.&lt;/li&gt;
&lt;li&gt;MFEs can be lazy-loaded to improve performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Container app needs to be rebuild and re-deployed every time any changes are made in MFE npm package.&lt;/li&gt;
&lt;li&gt;If multiple MFEs will be tightly coupled with Container app then there are chances that an MFE app will become a distributed monolithic app.&lt;/li&gt;
&lt;li&gt;In short your MFE is integrated with container app similar to an NPM package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How MFE apps integrates in Build Time Integration (here taking example of an E-commerce application)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Team #1, develops Products-List MFE app.&lt;/li&gt;
&lt;li&gt;Team #1 deploys Products-List MFE app and publish it as an NPM package.&lt;/li&gt;
&lt;li&gt;Team #2, managing container app, includes Products-List MFE app as an NPM package dependency in container app.&lt;/li&gt;
&lt;li&gt;Team #2, compiles and builds container app bundle, this bundle contains code of Container app including Products-List MFE app code as well.&lt;/li&gt;
&lt;li&gt;In short your MFE is integrated with container app similar to an NPM package.&lt;/li&gt;
&lt;li&gt;That’s it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Run Time integration (Client side Integration)&lt;/strong&gt;&lt;br&gt;
In this integration, Once container app is loaded in browser then it can access MFE apps by using urls of MFE apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Pros&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each MFE can be deployed without re-deploying container app.&lt;/li&gt;
&lt;li&gt;Different version of same MFE app can be used, container can decide which MFE version to use and when, it makes testing and integration easy.&lt;/li&gt;
&lt;li&gt;Each MFE app can have their own tools and libraries for development purpose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cons&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run Time MFEs are more complex to setup and integrate than build-time MFEs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How MFE apps integrates in Run Time Integration (here taking example of an E-commerce application)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Team #1, develops Products-List MFE app.&lt;/li&gt;
&lt;li&gt;Team #1 deploys Products-List MFE i.e. &lt;a href="https://mystore.in/productslist.js" rel="noopener noreferrer"&gt;https://mystore.in/productslist.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Team #2, managing container app, will use webpack-module-federation to integrate it with container app.&lt;/li&gt;
&lt;li&gt;When user opens &lt;a href="https://mystore.in/" rel="noopener noreferrer"&gt;https://mystore.in/&lt;/a&gt; , container app is loaded in browser and fetches Products-List MFE app and displays it in a defined location in container-app page.&lt;/li&gt;
&lt;li&gt;That’s it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Serve Side Integration (SSR Integration)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this Integration Micro-frontend app works in similar way as SSR components works. All MFEs apps are integrated at server end and a composited container app is returned to browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Pros&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;App loads faster.&lt;/li&gt;
&lt;li&gt;SEO friendly approach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Limited interactivity.&lt;br&gt;
Development challenge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thats it for now, Thank you for your time.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>microfrontends</category>
      <category>frontend</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
