SPA mode configuration causes app to hang on loading skeleton with Bun + Vite 7 #5171
Send to my agentDescription#
When using TanStack Start with Bun runtime and Vite 7, having the spa configuration object present (even when commented out internally) causes the application to get stuck showing the loading skeleton and never hydrate properly.
Environment#
- TanStack Start: Latest
- Vite: 7.1.6
- Runtime: Bun 1.2.23
- React: 19.1.1
Configuration that causes the issue#
// vite.config.ts
tanstackStart({
target: "bun",
customViteReactPlugin: true,
spa: {
// enabled: true,
},
}),
Working configuration#
// vite.config.ts
tanstackStart({
target: "bun",
customViteReactPlugin: true,
// spa: {
// // enabled: true,
// },
}),
Symptoms#
- Server starts successfully
- SSR returns loading skeleton HTML
- Client connects ("[vite] connected" in console)
- App remains in "pending" state and never hydrates
- No JavaScript errors in console
- Page shows only the animated loading skeleton
Expected behavior#
The app should either:
- Work correctly with an empty
spa: {}configuration object, or - Throw a clear error if the configuration is invalid
Workaround#
Completely commenting out the spa configuration object resolves the issue and allows the app to work normally in SSR mode.
schiller-manuel(GitHub profile, opens in a new tab) added labelsrevisit-after-rc
Seems like disabling spa mode explicitly works. I feel like SPA mode does not work in vite dev server somehow.
// vite.config.ts tanstackStart({ spa: { enabled: false, }, }),The best way I find is to disable SPA mode in dev in the vite config:
import { defineConfig } from 'vite'; import { tanstackStart } from '@tanstack/react-start/plugin/vite'; export default defineConfig(({ command }) => ({ plugins: [ tanstackStart({ spa: command === 'serve' ? undefined : { enabled: true, }, }), ], }));cc @nlynzaad
v1.131.48 contained https://github.com/TanStack/router/pull/5169 don't see yet how this is related to SPA mode?
Yeah I don't see how those can be related.
1.131.48 merely added tests and had one change in the parsing of paths, it came nowhere close to any of this.
I can confirm tonight.
I patched
@tanstack/router-core@1.131.48by changingdecodeURI(partToMatch)to(() => {console.log({ part, partToMatch }); return decodeURI(part)})().It works now! For context, 1.131.47 uses
decodeURI(part), while 1.131.48 usesdecodeURI(partToMatch).Console output shows:
[vite] connected. { part: '__root__', partToMatch: '__root_' } { part: '.', partToMatch: '.' } { part: '.well-known', partToMatch: '.well-known' } { part: 'appspecific', partToMatch: 'appspecific' } { part: 'com.chrome.devtools.json', partToMatch: 'com.chrome.devtools.json' } { part: '__root__', partToMatch: '__root_' } { part: '.', partToMatch: '.' }Seems like the slicing logic (
partToMatch = part.slice(-1) === '_' ? part.slice(0, -1) : part) is breaking the__root__route in 1.131.48.
Sign in to join this conversation.
Same issue here. Did a binary search and found 1.131.47 works, but 1.131.48 and up are broken. Hope that helps!