This demonstrates a microfrontend setup using Vite, @originjs/vite-plugin-federation, and multiple frameworks: Vue (host and remote), React, Svelte, and SolidJS.
root/
├─ vite-hostapp/ # Vue 3-based host application
├─ vite-remoteapp-1/ # React-based remote app
├─ vite-remoteapp-2/ # Vue-based remote app
├─ vite-remoteapp-3/ # Svelte-based remote app
├─ vite-remoteapp-4/ # SolidJS-based remote app
...
This mode is for when you want to run the full microfrontend architecture — the host loads remote apps' modules via module federation.
Remotes must be run in build/preview mode so the host can fetch the remoteEntry.js
files.
For each remote app (React, Vue, Svelte, SolidJS):
cd vite-remoteapp-N
npm install
npm run build
npm run preview
# The default preview port is usually 4173, but check your config/terminal for the correct port
Note: Make sure each remote is previewing on the port specified in your host's federation config.
For the host app (Vue-based):
cd vite-hostapp
npm install
npm run dev
# The host will fetch remote modules from the preview servers.
If you want to work on any remote app as a regular standalone SPA, launch it with a special config that disables federation.
For any remote app:
cd vite-remoteapp-N
npm install
npm run dev
# This uses vite --config vite.dev.config.ts and loads the app as standalone.
npm run dev
: Runs the app in standalone mode for individual development using vite --config vite.dev.config.ts
npm run build
: Builds the remote/host for preview or productionnpm run preview
: Serves the built app (remotes must use this for federation!)vite.config.ts
(for build/preview/federation usage).vite.dev.config.ts
to run as a normal SPA, with no federation.vite.config.ts
uses remote URLs matching your remotes' preview ports.Start all remote apps in preview mode:
cd vite-remoteapp-1 && npm run build && npm run preview
cd vite-remoteapp-2 && npm run build && npm run preview
Start host app:
cd vite-hostapp && npm run dev
The host loads remote components from the running preview servers.
npm run dev
for remotes during federation.remoteEntry.js
asset, which is only served in preview mode after build.npm run dev
only for local, standalone development/testing on a single remote app.