+ Router-aware remote
+ Remote uses the host router
+
+ This exposed component reads the host's TanStack Router context through a shared router
+ runtime.
+
+
+
+ Remote link
+
+
+
+
+ );
+}
diff --git a/apps/vite-remote/vite.config.ts b/apps/vite-remote/vite.config.ts
index ca36c2a..8d72433 100644
--- a/apps/vite-remote/vite.config.ts
+++ b/apps/vite-remote/vite.config.ts
@@ -9,8 +9,11 @@ export default defineConfig({
name: "tanstack_vite_remote",
dts: false,
// Workspace dependencies declare "workspace:*", which is not a semver range.
- shared: { "example-host-context": { requiredVersion: "*", singleton: true } },
+ shared: {
+ "example-host-context": { requiredVersion: "*", singleton: true },
+ },
exposes: {
+ "./RouterCard": "./src/components/RouterCard.tsx",
"./StatusCard": "./src/components/StatusCard.tsx",
},
}),
diff --git a/packages/tanstack/README.md b/packages/tanstack/README.md
index d419ffb..0a08f5e 100644
--- a/packages/tanstack/README.md
+++ b/packages/tanstack/README.md
@@ -53,10 +53,11 @@ Defaults:
- `filename: "remoteEntry.js"`, `manifest: true`, and
`hostInitInjectLocation: "entry"`.
-- `react` and `react-dom` are shared singletons. When the config declares
- `remotes`, they are also `eager`, so the host's own React stays in the share
- scope and a remote built by another bundler cannot replace it. Remote-only
- builds stay lazy.
+- `react`, `react-dom`, `@tanstack/react-router`, and `@tanstack/router-core`
+ are shared singletons. When the config declares `remotes`, they are also
+ `eager`, so the host's own React and Router runtimes stay in the share scope
+ and a remote built by another bundler cannot replace them. Remote-only builds
+ stay lazy.
- Any entry you pass in `shared` replaces the default for that package.
A Vite host renders before lazy shared modules resolve, so mark any other shared
@@ -129,8 +130,9 @@ can be consumed by Vite and Rsbuild hosts.
Defaults:
-- `react` and `react-dom` are shared singletons, `eager` for hosts (configs with
- `remotes`) and lazy for remote-only builds.
+- `react`, `react-dom`, `@tanstack/react-router`, and `@tanstack/router-core`
+ are shared singletons, `eager` for hosts (configs with `remotes`) and lazy
+ for remote-only builds.
- `experiments.asyncStartup: true`, so entries wait for shared modules before
running. Pass `experiments: { asyncStartup: false }` to opt out.
- A remote's browser build uses `publicPath: "auto"`, so hosts on other origins
diff --git a/packages/tanstack/src/node-entry-loader.ts b/packages/tanstack/src/node-entry-loader.ts
index 2bec321..c7d19f2 100644
--- a/packages/tanstack/src/node-entry-loader.ts
+++ b/packages/tanstack/src/node-entry-loader.ts
@@ -1,10 +1,23 @@
import type { ModuleFederation, ModuleFederationRuntimePlugin } from "@module-federation/runtime";
+import { tanstackStartSharedPackages } from "./shared";
type LoadEntryArgs = Parameters