<?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 Rithish Jakkireddy on Medium]]></title>
        <description><![CDATA[Stories by Rithish Jakkireddy on Medium]]></description>
        <link>https://medium.com/@rithishjakkireddy?source=rss-efc85fe2a9a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rz7m863qB2vpmdZ3MO4HXg.jpeg</url>
            <title>Stories by Rithish Jakkireddy on Medium</title>
            <link>https://medium.com/@rithishjakkireddy?source=rss-efc85fe2a9a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 15:25:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rithishjakkireddy/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[Micro Frontends with React, Vite & TypeScript: A Hands-On Guide]]></title>
            <link>https://medium.com/@rithishjakkireddy/micro-frontends-with-react-vite-typescript-a-hands-on-guide-9005fee02d21?source=rss-efc85fe2a9a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9005fee02d21</guid>
            <category><![CDATA[module-federation]]></category>
            <category><![CDATA[frontend-architecture]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[vites]]></category>
            <category><![CDATA[implement-microfrontend]]></category>
            <dc:creator><![CDATA[Rithish Jakkireddy]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 19:21:52 GMT</pubDate>
            <atom:updated>2025-06-16T19:48:03.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXdL0MQvK7ewGvZJwMj24Q.png" /></figure><blockquote>Step-by-step, production-ready setup using Module Federation and Vite.</blockquote><h3>TL;DR</h3><p>Clone <a href="https://github.com/Rithish891/mfe-starter">mfe-starter</a>, run two commands, and you’ll have a <strong>host</strong> and <strong>remote</strong> micro-frontend (MFE) talking to each other in &lt; 2 minutes. This post explains every file, why Module Federation matters, and how to avoid the most common traps.</p><h3>1. Why Micro-Frontends?</h3><blockquote>Our SPA’s cold build hit <strong>45 seconds</strong> — and every feature release felt like defusing a bomb.</blockquote><p>Micro-frontends break a big UI into autonomous mini-apps that can ship on their own cadence while still looking like one product. Module Federation (born in Webpack, now available in Vite) lets the browser load those mini-apps at <strong>runtime</strong>, share a single copy of React, and cache each bundle independently.</p><h3>2. Project at a Glance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DUJX296vSxR7C9-1ieZRgA.png" /></figure><p>Each repo is a standalone Vite + React + TypeScript app with its own vite.config.ts; the child <strong>exposes</strong> its App via @originjs/vite-plugin-federation, while the parent <strong>consumes</strong> it by listing the remote URL in its remotes map. Inside the parent, a tiny mfe.d.ts file declares declare module &#39;ChildMfe/App&#39;; so TypeScript recognises the federated import and gives you full type-safety and autocompletion.</p><h3>3. Bootstrapping the Apps</h3><pre># 1. Create two Vite templates (React + TS)<br>npm create vite@latest parent-mfe -- --template react-ts<br>npm create vite@latest child-mfe  -- --template react-ts<br><br># 2. Install the federation plugin in both<br>npm i -D @originjs/vite-plugin-federation</pre><p><strong>Prereqs:</strong> Node ≥ 20, Git, and (optionally) pnpm 8.</p><h3>4. Configuring Module Federation</h3><p>4.1 Child (Remote) — child-mfe/vite.config.ts</p><pre>import { defineConfig } from &quot;vite&quot;;<br>import react from &quot;@vitejs/plugin-react&quot;;<br>import federation from &quot;@originjs/vite-plugin-federation&quot;;<br><br>export default defineConfig({<br>  plugins: [<br>    react(),<br>    federation({<br>      /* unique name for this MFE */<br>      name: &quot;child-mfe&quot;,<br>      /* runtime manifest the host will fetch */<br>      filename: &quot;remoteEntry.js&quot;,<br>      /* components we export */<br>      exposes: {<br>        &quot;./App&quot;: &quot;./src/App.tsx&quot;,<br>      },<br>      /* keep only one copy of each lib in the browser */<br>      shared: [&quot;react&quot;, &quot;react-dom&quot;],<br>    }),<br>  ],<br>});</pre><p>This produces remoteEntry.js, the runtime contract other MFEs can import.</p><p>4.2 Parent (Host) — parent-mfe/vite.config.ts</p><pre>import { defineConfig } from &quot;vite&quot;;<br>import react from &quot;@vitejs/plugin-react&quot;;<br>import federation from &quot;@originjs/vite-plugin-federation&quot;;<br><br>export default defineConfig({<br>  plugins: [<br>    react(),<br>    federation({<br>      name: &quot;parent-mfe&quot;,<br>      /* alias : URL to remoteEntry (swap via env var in CI) */<br>      remotes: {<br>        ChildMfe: {<br>          external: &quot;http://localhost:4174/assets/remoteEntry.js&quot;,<br>          externalType: &quot;url&quot;,<br>        },<br>      },<br>      shared: [&quot;react&quot;, &quot;react-dom&quot;],<br>    }),<br>  ]<br>});</pre><p><strong>Tip:</strong> In CI/CD you’ll swap the localhost URL for an environment variable that points to the deployed remote bundle.</p><h3>5. Consuming the Remote in React</h3><pre>// parent-mfe/src/App.tsx<br>import { lazy, Suspense } from &#39;react&#39;;<br><br>const Child = lazy(() =&gt; import(&#39;ChildMfe/App&#39;));   // ← magic alias<br><br>export default function App() {<br>  return (<br>    &lt;Suspense fallback={&lt;p&gt;Loading child…&lt;/p&gt;}&gt;<br>      &lt;Child /&gt;<br>    &lt;/Suspense&gt;<br>  );<br>}</pre><p>Tip 🎯 Add an <strong>Error Boundary</strong> around lazy remotes in prod to surface network issues.</p><h3>6. Type-Safety Across MFEs</h3><p>Create <strong>parent-mfe/src/mfe.d.ts</strong> so TypeScript recognises the remote module:</p><pre>declare module &quot;ChildMfe/App&quot;;</pre><p>Now your IDE autocompletes remote props and flags breaking changes at compile time.</p><blockquote><strong>Pro trick:</strong> publish dist/remote.d.ts from each remote and point to it in package.json → types so downstream packages get typed imports automatically.</blockquote><h3>7. Running Locally</h3><pre># Terminal ① – start the child<br>cd child-mfe<br>npm run dev      # defaults to :5173, Vite will choose the next free port<br><br># Terminal ② – start the parent<br>cd ../parent-mfe<br>npm run dev</pre><p>Check the console; if 5173 is busy, Vite bumps to the next port.</p><h3>8. Deployment Strategy 🚀</h3><ul><li><strong>Independent pipelines</strong> — each MFE lives in its own repo or folder and can be deployed whenever it’s ready.</li><li><strong>Remote first</strong> — always deploy remotes, then bump the host to reference the new version.</li><li><strong>Version pinning</strong> — use semantic versioning in the host’s remotes map or load the manifest from a URL that includes the version tag (e.g. <em>cdn.com/child@1.3.0/remoteEntry.js</em>).</li><li><strong>Cache busting</strong> — fingerprints plus long-term caching on remotes; the host invalidates by switching to a new file name.</li></ul><h3>9. Scaling to Many MFEs</h3><ul><li>Multiple remotes = more entries under remotes.</li><li>Heavy libs (react, @tanstack/react-query, design tokens) go in <strong>shared</strong>.</li><li>Keep remote APIs small, stable, versioned.</li></ul><h3>10. Common Pitfalls &amp; Fixes 🩹</h3><figure><img alt="Table mapping four common errors to their solutions" src="https://cdn-images-1.medium.com/max/1024/1*zpWY-qhFbrGbYIa0E5u4jQ.png" /></figure><h3>11. Where to Go Next</h3><ul><li>Add a second remote (e.g., auth MFE) and share Redux store via shared.</li><li>Create a Jest test that mocks ChildMfe/App to prove isolation.</li><li>Publish each remote to a CDN and swap URLs via VITE_CHILD_MFE_URL env var in the host.</li></ul><h3>⭐ Wrap-Up &amp; CTA</h3><p>You now have a <strong>production-ready micro-frontend baseline</strong> that compiles in seconds and deploys independently. Clone the repo, try it in your own project, and <strong>star the GitHub repo</strong> if this saved you hours!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9005fee02d21" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>