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 portNote: 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.- This enables fast HMR and regular SPA behavior for isolated development.
- You can access the app at the port specified in config.
npm run dev: Runs the app in standalone mode for individual development usingvite --config vite.dev.config.tsnpm run build: Builds the remote/host for preview or productionnpm run preview: Serves the built app (remotes must use this for federation!)
- Remote apps: Main federation config is in
vite.config.ts(for build/preview/federation usage). - Standalone mode: Uses
vite.dev.config.tsto run as a normal SPA, with no federation. - Host app: Federation config in
vite.config.tsuses remote URLs matching your remotes' preview ports.
-
Start all remote apps in preview mode:
cd vite-remoteapp-1 && npm run build && npm run previewcd vite-remoteapp-2 && npm run build && npm run preview- ...repeat for other remotes
-
Start host app:
cd vite-hostapp && npm run dev
-
The host loads remote components from the running preview servers.
- Never use
npm run devfor remotes during federation.
The host requires theremoteEntry.jsasset, which is only served in preview mode after build. - Use
npm run devonly for local, standalone development/testing on a single remote app. - Each app can be further customized—refer to its README or configs for framework-specific notes (Coming soon).
- Built with Vite and @originjs/vite-plugin-federation.
- Example covers federated microfrontends in React, Vue, Svelte, and SolidJS.