11# @module-federation/tanstack
22
3- Module Federation support for TanStack Start, built on the Vite integration.
3+ Module Federation support for TanStack Start on Vite and Rsbuild. Rsbuild uses
4+ Rspack under the hood.
45
56## Install
67
78``` bash
89pnpm add @module-federation/tanstack @tanstack/react-start
910```
1011
12+ Install the adapter for the bundler you use. They are optional peers so an
13+ Rsbuild-only application does not install or resolve the Vite adapter, and a
14+ Vite-only application does not install or resolve the Rsbuild adapter.
15+
16+ ``` bash
17+ pnpm add @module-federation/vite vite # Vite
18+ pnpm add @module-federation/rsbuild-plugin @rsbuild/core # Rsbuild
19+ ```
20+
1121## Configure
1222
1323The federation wrapper must come before ` tanstackStart() ` so Module Federation
1424can normalize TanStack's client and SSR entrypoints:
1525
1626``` ts
17- import { tanstackStartModuleFederation } from " @module-federation/tanstack" ;
27+ import { tanstackStartModuleFederation } from " @module-federation/tanstack/vite " ;
1828import { tanstackStart } from " @tanstack/react-start/plugin/vite" ;
1929import react from " @vitejs/plugin-react" ;
20- import { nitro } from " nitro/vite" ;
2130import { defineConfig } from " vite" ;
2231
2332export default defineConfig ({
@@ -34,7 +43,6 @@ export default defineConfig({
3443 }),
3544 tanstackStart (),
3645 react (),
37- nitro (),
3846 ],
3947});
4048```
@@ -51,15 +59,51 @@ The package supports Node 22.18+, 24.11+, and 26+, plus Vite 7/8 and TanStack
5159Start 1.x. Use Vite 8 when developing SSR hosts that load remotes; Vite 7
5260remains supported for production builds.
5361
62+ The package root remains a Vite compatibility export. New Vite projects can
63+ import ` /vite ` explicitly. Rsbuild projects must import ` /rsbuild ` :
64+
65+ ``` ts
66+ import { defineConfig } from " @rsbuild/core" ;
67+ import { pluginReact } from " @rsbuild/plugin-react" ;
68+ import { tanstackStart } from " @tanstack/react-start/plugin/rsbuild" ;
69+ import { tanstackStartModuleFederation } from " @module-federation/tanstack/rsbuild" ;
70+
71+ export default defineConfig ({
72+ plugins: [
73+ pluginReact (),
74+ tanstackStart (),
75+ ... tanstackStartModuleFederation ({
76+ federation: {
77+ name: " host" ,
78+ remotes: { remote: " remote@https://example.test/mf-manifest.json" },
79+ },
80+ }),
81+ ],
82+ });
83+ ```
84+
85+ The Rsbuild adapter registers browser and SSR federation plugins by default. It
86+ emits script-compatible browser output and async-node CommonJS SSR output so
87+ its manifest can be consumed by Vite and Rsbuild hosts. The wrapper adds eager,
88+ singleton ` react ` and ` react-dom ` entries without changing the caller's config
89+ object. Set ` server: false ` for browser-only remotes.
90+
91+ Server federation mode emits ` dist/server/index.cjs ` ; browser-only mode keeps
92+ TanStack Start's standard ` dist/server/index.js ` entry.
93+
5494## Example
5595
56- The workspace includes two TanStack Start apps. ` apps/remote ` exposes a
57- stateful React card, and ` apps/host ` consumes it through this package.
96+ The workspace includes Vite and Rsbuild pairs. ` apps/remote ` exposes a
97+ stateful React card to ` apps/host ` . ` apps/rsbuild-remote ` exposes a second card
98+ to the Vite host, while ` apps/rsbuild-host ` consumes the Vite remote. Both
99+ cross-bundler links use manifest URLs. They render after hydration, so this is
100+ browser interop coverage, not an unverified SSR interoperability claim.
58101
59102``` bash
60103pnpm install
61104pnpm start
62105```
63106
64- Open the host at http://localhost:3000 . The remote also runs as its own
65- TanStack Start application at http://localhost:3001 .
107+ This starts all four applications so both same-bundler and cross-bundler paths
108+ are available. Open the Vite host at http://localhost:3000 or the Rsbuild host
109+ at http://localhost:3003 .
0 commit comments