Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Vite + React microfrontends starter using single-spa and Module Federation on Vercel.
This Vercel example starter demonstrates how to build a microfrontend architecture using single-spa and Module Federation, with two React applications that deploy independently to Vercel. The monorepo includes a root shell application, a content application, and shared TypeScript/ESLint configuration packages, all running on Vite with the @module-federation/vite plugin and the @vercel/microfrontends/experimental/vite plugin.
The Microfrontends single-spa Starter is a working reference implementation from Vercel's examples repository. It takes a monorepo setup as its input — two Vite-powered React apps plus shared packages — and produces a single page where the root app orchestrates the header, footer, and a content landing component from separate applications. The content app exposes a ./landing module through Module Federation, and the root app imports it at runtime as the remote content, using single-spa to manage the application lifecycle with bootstrap, mount, and unmount functions.
microfrontends.json groups them together.registerApplication, and each loading function uses dynamic ES module imports.name: 'content', manifest: true, and filename: 'remoteEntry.js', exposing the ./landing component.content as a remote with entry /_content/remoteEntry.js, sharing React and React DOM as singletons.microfrontends.json file defines the applications, routing paths, and a development fallback URL; the local proxy listens on port 3024 by default.@tailwindcss/vite and share a global CSS file for utility-first styling.vercelToolbar() Vite plugin and calls mountVercelToolbar() in its startup code.packages/ directory holds common TypeScript configurations, ESLint rules, and formatting standards used across the microfrontends./_content/.index.html has dedicated mount points for header, content, and footer, while the TypeScript entry registers each one as a single-spa application active on every route.pnpm install, then pnpm dev to start all applications and the Microfrontends proxy; open http://localhost:3024 to see the federated page.microfrontends.json configuration that maps the content app to /_content/:path* routes.The starter uses two Vite configurations. The content app exposes the landing component through the @module-federation/vite plugin, and the root app declares that remote in its own config. At runtime, single-spa calls the registered loading functions, which dynamically import the remote entry and mount the React component using single-spa-react. The microfrontends.json file controls both the development proxy and production routing on Vercel.
It uses Vite as the build tool, React and TypeScript for the applications, Tailwind CSS for styling, single-spa for lifecycle orchestration, and the @module-federation/vite and @vercel/microfrontends/experimental/vite plugins. Package management is handled with pnpm.
The Microfrontends proxy defaults to port 3024, and the root application is available at http://localhost:3024. To change this, set localProxyPort in the microfrontends.json file.
The configuration sets build.target: 'chrome89' because the example needs top-level await support, which is available in Chrome 89 and later browsers. This is required for the microfrontend runtime to load remote modules asynchronously.
Yes. The example includes separate Vercel Deploy buttons for each application. The root app acts as the default entry point, while the content app is routed to paths starting with /_content/ according to the microfrontends.json configuration.
