<?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 Prasad Naik on Medium]]></title>
        <description><![CDATA[Stories by Prasad Naik on Medium]]></description>
        <link>https://medium.com/@reachprasadnaik?source=rss-a14d8472acf5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CAUXaZq7Pqd7L03O6-trSA.png</url>
            <title>Stories by Prasad Naik on Medium</title>
            <link>https://medium.com/@reachprasadnaik?source=rss-a14d8472acf5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:47:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@reachprasadnaik/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 in Production: The Problems Nobody Warns You About]]></title>
            <link>https://medium.com/@reachprasadnaik/micro-frontends-in-production-the-problems-nobody-warns-you-about-f022cc669ad1?source=rss-a14d8472acf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f022cc669ad1</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Prasad Naik]]></dc:creator>
            <pubDate>Mon, 29 Jun 2026 16:50:44 GMT</pubDate>
            <atom:updated>2026-06-29T16:50:44.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kvHzaaSRenIPwNMftXqQVQ.png" /></figure><p>After over five years of frontend development — and plenty of conversations about micro frontends that never led anywhere — I finally found the perfect use case.</p><p>We had two production React apps, each a standalone Vite SPA with its own domain, its own auth session, and its own release cycle. They served different user needs, but the audience overlapped heavily. Users bounced between two browser tabs, re-authenticated each time, and lost all sense of continuity. The business wanted them under one roof: a single URL, a single login, and a seamless product switcher that made it feel like one application.</p><p>The moment that requirement landed, one word came to mind — <em>Microfrontend</em>.</p><p>We chose Module Federation to unify both apps under a new host shell. This post isn’t a how-to guide for setting up micro frontends — there are plenty of those already. Instead, it’s about the problems we ran into along the way, the ones no tutorial warned us about, and how we solved them.</p><blockquote>Quick primer: micro frontends split a monolithic SPA into independently deployed pieces, stitched together at runtime by a host shell. You gain team autonomy — but inherit new problems. Those problems are what this post is about.</blockquote><h3>The Target Architecture</h3><p>A new <strong>host shell</strong> owns three things: authentication, top-level routing, and a product switcher component that lets users move between apps without a page reload. Each product app becomes a <strong>remote</strong> — exposed via a remoteEntry.js file, loaded lazily with React.lazy + Suspense, and wrapped in an error boundary.</p><p>The remotes continue to work as standalone apps for local development. In MFE mode, they skip their own auth bootstrap and receive a flag from the shell indicating auth is already initialized.</p><h3>Problem 1: React Version Conflicts and Duplicate Instances</h3><p>This was the first problem we hit. Our two apps had drifted to slightly different React versions over time. Module Federation happily loaded both, which meant two copies of React in the browser — two virtual DOMs, broken hooks, cryptic “Invalid hook call” errors.</p><p><strong>The fix:</strong> We aligned both remotes on the same React version and declared these as shared singletons:</p><ul><li>react</li><li>react-dom</li><li>react/jsx-runtime</li><li>react/jsx-dev-runtime</li></ul><p>The last two were a gotcha. Vite’s JSX transform imports from react/jsx-runtime at build time, and if that module isn&#39;t explicitly shared, each remote gets its own copy — which internally references a different React instance. We only caught this after the initial &quot;it works in dev but breaks in production&quot; cycle.</p><p>We also added react-redux, @reduxjs/toolkit, and react-router-dom to the shared list in a subsequent optimization pass. The principle: <strong>any library that relies on React context or a global singleton must be shared</strong>, or you&#39;ll get subtle bugs where context providers in the shell can&#39;t communicate with consumers in the remotes.</p><h3>Problem 2: Auth Provider Reloaded on Every App Switch</h3><p>With React unified, this became the most user-visible issue. In the standalone world, each app created its own auth client instance and ran initialization on mount. When we first federated them, that behavior carried over — every time a user switched from Product A to Product B (or back), the newly mounted remote would spin up a fresh auth client, trigger a redirect, and flash a white screen.</p><p><strong>Root cause:</strong> Two independent auth client instances, each hitting the identity provider.</p><p><strong>The fix had two parts:</strong></p><p>First, we moved auth ownership entirely to the shell. The shell wraps both remotes in a single auth provider. Remotes no longer import or initialize the auth client themselves — they receive an isAuthReady prop and render immediately.</p><p>Second, we declared the auth client library as a <strong>shared singleton</strong> in the Module Federation config. This was the piece we initially missed. Without it, each remote bundled its own copy of the auth client library, so even though the shell had already authenticated, the remote’s copy didn’t know that. Marking it as a singleton ensures every federated module resolves to the same instance at runtime.</p><pre>// Remote bootstrap — no auth initialization<br>const RemoteBootstrap = () =&gt; &lt;Application isAuthReady /&gt;;<br>export default RemoteBootstrap;</pre><p>The result: switching between products is now a React route transition. No auth redirects, no white flash.</p><h3>Problem 3: Slow Initial Load</h3><p>After the first working integration, initial page load was noticeably slower than the standalone apps. The federation handshake — where the host resolves shared dependencies, fetches remote entries, and negotiates versions — added visible delay.</p><p>We traced this to three causes and fixed each:</p><p><strong>1. Library version regression.</strong> The Module Federation Vite plugin introduced a performance regression in a minor version bump. The federation handshake that previously took ~200ms ballooned. We pinned the plugin to the last known-good version. Lesson: <strong>treat your federation plugin version as carefully as you’d treat your bundler version.</strong> A patch bump can change how shared import maps are generated.</p><p><strong>2. Too much loaded upfront.</strong> On first load, the browser was fetching chunks for both remotes even though the user was only visiting one product. We restructured loading so that only the shell, React, and the auth client load initially. The active remote’s chunks load next. The other remote’s chunks don’t load at all until the user navigates to it.</p><p>For the default product, we added a &lt;link rel=&quot;preload&quot;&gt; for its remote entry in the shell&#39;s HTML, shaving one network round-trip off the critical path.</p><p><strong>3. Shared import map bloat.</strong> The federation runtime generates internal files that map shared dependencies to their resolved locations. After the plugin pin, these regenerated cleanly — 128 lines of mappings that the runtime uses to resolve singletons without redundant downloads.</p><h3>What We Got Right Early</h3><p>Not everything was painful. A few decisions paid off from day one:</p><p><strong>Thin remote entry points.</strong> Each remote exposes a single RemoteBootstrap component that imports the app&#39;s root component and passes isAuthReady. No routing logic, no providers, no side effects. This kept the contract between shell and remote minimal and easy to reason about.</p><p><strong>MFE detection helpers.</strong> A small utility module exports an isMfeBuild flag derived from the Vite build mode. Components that behave differently in standalone vs. federated mode (version checking, analytics initialization) branch on this flag rather than sniffing the environment at runtime.</p><p><strong>Environment-configurable remote URLs.</strong> The shell resolves remote entry URLs from environment variables, not hardcoded strings. This let us point dev, QA, and production at different remote deployments without code changes.</p><h3>Things We Removed Along the Way</h3><p>Migration isn’t just additive. We deleted a surprising amount of code:</p><p><strong>Route prefix manipulation.</strong> We initially wrote a helper that prefixed the product’s base path onto public route paths (demo pages, embedded widgets) when running as a remote. It turned out to be unnecessary — the shell’s path-based routing already handles the prefix, and remotes use a configured basename internally. The helper was adding complexity to solve a problem the architecture had already solved.</p><p><strong>Redundant error handling.</strong> One remote had a flow for handling “unauthorized email domain” errors that redirected users to the other product. This made sense when the apps were standalone, but under the shell it created a redirect loop. We removed it and let the shell handle authorization uniformly.</p><p><strong>Per-app version checking.</strong> Each standalone app polled a version.json file to detect new deployments and prompt users to refresh. In the federated setup, the shell registers a global function that remotes call instead of implementing their own polling. One version check, one refresh prompt, regardless of which product is active.</p><h3>Architecture Trade-offs Worth Acknowledging</h3><p><strong>Coupling increased.</strong> The shell, both remotes, and shared dependency versions are now loosely coupled. A React major version bump requires coordinating across three repos. We accepted this because the user experience gain (seamless product switching, single auth) outweighed the coordination cost.</p><p><strong>Local development got more complex.</strong> Running the full federated setup locally means starting three dev servers on specific ports. We scripted this, but it’s still heavier than npm run dev on a single app. Most day-to-day feature work happens in standalone mode; federated testing happens in a shared dev environment.</p><p><strong>The shell is a single point of failure.</strong> If the shell’s deployment breaks, both products are down. We mitigated this with aggressive caching of the shell’s static assets and keeping the shell’s codebase minimal — it’s routing, auth, and a product switcher, nothing else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7HkK8qoLgjK61dfg35-gw.png" /><figcaption>Before and after implementing micro frontend</figcaption></figure><h3>Key Takeaways</h3><ol><li><strong>Auth belongs in the shell, period.</strong> Don’t let remotes initialize their own auth clients. Declare the auth library as a shared singleton and pass readiness as a prop.</li><li><strong>Share more than you think.</strong> Any package that uses React context, maintains global state, or assumes a single instance needs to be in the shared config. Start with the obvious (React) but audit for implicit imports like jsx-runtime.</li><li><strong>Pin your federation tooling.</strong> The Module Federation plugin is not a “set and forget” dependency. Minor versions can change how shared imports are resolved and introduce real performance regressions.</li><li><strong>Lazy load aggressively.</strong> Only load what the current route needs. Preload the default remote’s entry point; defer everything else until navigation.</li><li><strong>Delete the scaffolding.</strong> Once the shell handles routing and auth, go back and remove the workarounds your remotes built for the standalone world. That dead code will confuse the next person.</li></ol><p><em>This migration took our two standalone products from separate-domain, separate-session apps to a unified shell with seamless switching and a single authentication flow. The hardest parts weren’t the Module Federation config itself — they were the second-order effects: duplicate library instances, auth lifecycle conflicts, and load-time regressions that only surfaced in production-like environments.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*zPpid2wl86A1WHRhSwuZeg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f022cc669ad1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Hosting Multiple Frontend Projects on a Single Domain]]></title>
            <link>https://medium.com/@reachprasadnaik/the-art-of-hosting-multiple-frontend-projects-on-a-single-domain-6fcfe69fbe09?source=rss-a14d8472acf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fcfe69fbe09</guid>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Prasad Naik]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 19:20:06 GMT</pubDate>
            <atom:updated>2024-02-12T19:20:06.406Z</atom:updated>
            <content:encoded><![CDATA[<p>Working on a product from scratch and maintaining it for years can be tough, but when management decides to deprecate it and build v2, it can be a hard pill to swallow. Later, you may realize that it was a wise decision, but a lot of code is often written in a rush to reduce time-to-market, making it inflexible and sometimes full of hacks — what we call ‘Jugaad’. Also, if the application is D2C, you need to ensure that the UI/UX is top-notch to keep customers engaged. So, love your project, but don’t be blind in love!</p><figure><img alt="Hosting multiple projects under same domain without user realizing it." src="https://cdn-images-1.medium.com/max/1024/0*4r01x4ZJ9mfvxj3t" /></figure><h3>Easier said than done!</h3><ol><li>New technology: If v2 uses a different technology from v1, it can be difficult and time-consuming to learn and implement. This can also lead to technical debt if not understood correctly.</li><li>Feature parity with v1: In startups, features are often developed with little to no documentation, leading to the possibility of forgetting a feature during migration.</li><li>Supporting legacy products: Even after completing v2, supporting existing versions can take months to a year, depending on the client base.</li><li>Migrating all modules: If a product has multiple modules, migrating all of them can take a long time, leading to delays and inactive modules in the repository.</li><li>Hosting v2: Hosting v2 on the same domain as v1 can be difficult, especially if both projects use different technologies, and supporting both simultaneously can be a challenge.</li></ol><p>Problem one is a tech skill problem or just laziness in reading documentation; the other three are more product management problems, while the last one is an interesting tech challenge to solve. This blog is all about solving these problems! So<em> Avengers, assemble!</em></p><h3>Let’s think of solution instead of problems</h3><p>Let’s say v1 of the product is hosted on some-product.my-company.com. v2 of the product needs to be hosted on the same domain, but we can have a different path — let’s say some-product.my-company.com/cool-path.</p><p>There can be multiple reasons for this.</p><ol><li>Maintaining the brand identity. People are used to your domain. Trust is already built for the domain. Changing it will mean starting from scratch.</li><li>There will be logins to this domain. If we change the domain, all the logins will be lost (in the case of domain-based authentication systems).</li><li>Other modules that are not yet migrated are still on the old domain.</li><li>And the list can increase depending on different use-cases.</li></ol><p>So, how do we solve this problem?</p><p>Before jumping to solve the problem, we need to decide on what hosting solution we should use. There are a number of options; I am listing a few below with their pros and cons:</p><p><strong>Netlify</strong><br>Netlify is a cloud-based platform that offers both hosting and continuous deployment for web applications. It is a great choice for static websites and small web applications.</p><p>Pros:</p><ul><li>Free tier available</li><li>Continuous deployment and Git integration</li><li>CDN for fast content delivery</li><li>HTTPS support</li></ul><p>Cons:</p><ul><li>Limited functionality for large applications</li><li>Limited database support</li></ul><p><strong>Firebase</strong><br>Firebase is a mobile and web application development platform by Google that offers hosting, databases, and other tools for building web applications. It is a great choice for small to medium-sized web applications that require real-time updates.</p><p>Pros:</p><ul><li>Easy to use and deploy</li><li>Real-time database support</li><li>Scalable</li></ul><p>Cons:</p><ul><li>Limited database support</li><li>Pricing can get expensive for larger applications</li></ul><p>Vercel<br>Vercel is a cloud-based platform that provides hosting, deployment, and serverless functions for web applications. It is a popular option for developers who want a seamless and fast deployment experience.</p><p>Pros:</p><ul><li>Easy to use</li><li>Continuous deployment and Git integration</li><li>Server-less functions</li><li>Custom domains</li></ul><p>Cons:</p><ul><li>Limited database support</li><li>Expensive for larger web applications</li><li>Limited control over infrastructure</li></ul><p>There are other solutions available which I’ll leave for you to explore. Please leave a comment if you are interested in a larger discussion about this.</p><figure><img alt="Hosting Solutions" src="https://cdn-images-1.medium.com/max/597/0*v_gNv94RO6Kz5OhM" /></figure><p>We are going forward with Vercel because of the ease of hosting via vercel’s proxy capabilities, which we are going to exploit for hosting all our versions under one roof. You can find official docs of Vercel <a href="https://vercel.com/docs">here</a></p><p>Vercel supports multiple frameworks. We are using React in this example for our base project (v1 project). You can host your git project on vercel within a few minutes.</p><p>Host your new project on vercel itself. Once hosted, you will get a hosted link for your project. Lets say its <a href="https://new-project.vercel.app/">https://new-project.vercel.app</a></p><p>Then you are almost ready to host these projects in one domain.</p><p>Just add the vercel.json file in your base project which is hosted on some-product.my-company.com with the following rewrites.</p><pre><br>{<br>      &quot;source&quot;: &quot;/v2/:match*&quot;,<br>      &quot;destination&quot;: &quot;https://new-project.vercel.app/v2/:match*&quot;<br>}</pre><p>Above code just proxy all requests for <a href="https://some-product.my-company.com/cool-path/cool-path/*">https://some-product.my-company.com/v2/match*</a> to <a href="https://new-project.vercel.app/cool-path/:match*">https://new-project.vercel.app/v2/:match*</a></p><p>Just remember that if your project is built with a framework that uses basePath config, you’ll need to configure this to the subpath used in your rewrite.</p><p>Side Note: You may also like to explore <a href="https://vercel.com/docs/concepts/projects/project-configuration#redirects">vercel redirects</a> along with <a href="https://vercel.com/docs/concepts/projects/project-configuration#rewrites">vercel rewrites</a></p><p>This will be required if the Base project is built using a framework that does not use basePath and the new project which uses the same.<br>In config file of your vX project (X being version number) just add basePath: ‘/cool-path/’<br>Also remember all your public assets paths will also need to be updated.</p><p>You may extract this out in a function which decides the base path depending on the environment. Example:</p><pre>const getAsset = (assetPath: string) =&gt; {<br>  const version_number = process ? process.env.APP_VERSION : &quot;1&quot;;<br>  const basePath = `/v${version_number}/assets`;<br>  return `${basePath}/${assetPath}`;<br>};</pre><h3>Conclusion</h3><p>No matter how attached you are to your ‘baby project’, you should know when to stop putting patches to the same code and start over and think of building V2. Yes, there can be many problems you’ll face in the process but you will find the solutions, and sometimes you will create the solutions. I tried to address one of the problems here.</p><p>That’s all for this blog. Thanks for reading!</p><figure><img alt="Framework meme" src="https://cdn-images-1.medium.com/max/598/0*4KgkPOtAwq-vXBfr" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fcfe69fbe09" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>