Use Module Federation in Tauri apps with @module-federation/tauri and the companion Rust plugin tauri-plugin-module-federation.
Important
@module-federation/tauri rewrites remote entries to the module-federation:// protocol. Your Tauri app must register tauri-plugin-module-federation so those requests can be fetched, cached, and replayed offline.
- A Module Federation runtime plugin for Tauri hosts.
- A Tauri custom protocol handler that fetches and caches remote assets.
- Offline fallback when a remote module has already been fetched once.
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
export default {
plugins: [
pluginModuleFederation({
name: 'host',
remotes: {
remote: 'remote@http://localhost:3002/remoteEntry.js',
},
runtimePlugins: ['@module-federation/tauri'],
}),
],
};tauri::Builder::default()
.plugin(tauri_plugin_module_federation::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");- Host app:
example/hostonhttp://localhost:3001 - Guest app:
example/guestonhttp://localhost:3002 - Guest app 2:
example/guest-2onhttp://localhost:3003 - Start all apps from repo root with
pnpm dev - More example details:
example/README.md
- Remote entry URLs are rewritten from
http(s)://...tomodule-federation://.../?fullUrl=.... - The Tauri plugin fetches those assets over the network and stores them in the app cache dir.
- Cache keys are derived from the remote host and request path.
- If a later fetch fails, the cached asset is served instead.
pnpm install
pnpm build- Rust plugin:
packages/tauri-plugin - Runtime package:
packages/tauri - Example apps:
example/*
MIT