diff --git a/packages/router-core/src/load-matches.ts b/packages/router-core/src/load-matches.ts index 838d77e9d38..77be3d4bcc4 100644 --- a/packages/router-core/src/load-matches.ts +++ b/packages/router-core/src/load-matches.ts @@ -416,6 +416,10 @@ const executeBeforeLoad = ( const pending = () => { if (isPending) return isPending = true + if (isServer ?? inner.router.isServer) { + match.abortController = abortController + return + } inner.updateMatch(matchId, (prev) => ({ ...prev, isFetching: 'beforeLoad', @@ -430,6 +434,9 @@ const executeBeforeLoad = ( const resolve = () => { match._nonReactive.beforeLoadPromise?.resolve() match._nonReactive.beforeLoadPromise = undefined + if (isServer ?? inner.router.isServer) { + return + } inner.updateMatch(matchId, (prev) => ({ ...prev, isFetching: false, @@ -676,10 +683,12 @@ const runLoader = async ( ) if (willLoadSomething) { - inner.updateMatch(matchId, (prev) => ({ - ...prev, - isFetching: 'loader', - })) + if (!(isServer ?? inner.router.isServer)) { + inner.updateMatch(matchId, (prev) => ({ + ...prev, + isFetching: 'loader', + })) + } } if (route.options.loader) {