diff --git a/.changeset/odd-tools-work.md b/.changeset/odd-tools-work.md new file mode 100644 index 0000000000..1ecfdba7e8 --- /dev/null +++ b/.changeset/odd-tools-work.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +Remove `Navigator` declaration for `navigator.connection.saveData` to avoid messing with any other types beyond `saveData` in userland diff --git a/packages/react-router/lib/dom/ssr/fog-of-war.ts b/packages/react-router/lib/dom/ssr/fog-of-war.ts index 741c280792..87a3ff3246 100644 --- a/packages/react-router/lib/dom/ssr/fog-of-war.ts +++ b/packages/react-router/lib/dom/ssr/fog-of-war.ts @@ -9,12 +9,6 @@ import type { EntryRoute } from "./routes"; import { createClientRoutes } from "./routes"; import type { ServerBuild } from "../../server-runtime/build"; -declare global { - interface Navigator { - connection?: { saveData: boolean }; - } -} - // Currently rendered links that may need prefetching const nextPaths = new Set(); @@ -115,7 +109,8 @@ export function useFogOFWarDiscovery( // Don't prefetch if not enabled or if the user has `saveData` enabled if ( !isFogOfWarEnabled(routeDiscovery, ssr) || - navigator.connection?.saveData === true + // @ts-expect-error - TS doesn't know about this yet + window.navigator?.connection?.saveData === true ) { return; }