Which project does this relate to?#
Start
Describe the bug#
A createServerFn called from root route beforeLoad returns undefined during client-side navigation in Vite dev.
The same server function works during SSR, and a direct fetch to the generated server function URL returns 200 with a serialized result.
Repro output:
[serverFn beforeLoad repro] {
environment: 'server',
auth: { userId: 'user_mock_repro', token: 'token_mock_repro' }
}
[serverFn beforeLoad repro] {
environment: 'browser',
auth: 'undefined'
}
[serverFn beforeLoad repro] raw serverFn fetch {
status: 200,
ok: true,
serialized: 'true',
hasSerializedResult: true,
hasUserId: true,
hasToken: true
}
Complete minimal reproducer#
https://github.com/TomoFromEarth/tanstack-start-clerk-beforeload-repro
Steps to Reproduce the Bug#
- Clone the repo:
git clone https://github.com/TomoFromEarth/tanstack-start-clerk-beforeload-repro.git
cd tanstack-start-clerk-beforeload-repro
- Install and run:
pnpm install
pnpm dev
Open http://localhost:3000.
Click between Home and Repro.
Observe the browser console/dev server logs. During browser-side navigation, fetchAuth() returns undefined, then the raw fetch to the same server function URL returns 200 with a serialized result.
Expected behavior#
Expected: await fetchAuth() returns the server function result during client navigation.
Actual: await fetchAuth() returns undefined, while the underlying endpoint returns the expected serialized payload.
Screenshots or Videos#
No response
Platform#
- Router / Start Version: @tanstack/react-router 1.170.16 / @tanstack/react-start 1.168.26
- OS: macOS 26.3.1
- Browser: Chrome
- Browser Version: 149.0.7827.197 (Official Build) (arm64)
- Bundler: Vite
- Bundler Version: 7.3.2
Additional context#
A hard refresh/direct load of the route works because beforeLoad runs through the SSR path and receives the server function result.
i wasnt able to reproduce this using your project.