T
TanStack3w ago
other-emerald

SPA mode error when deploying to CF

im getting a TypeError: Cannot read properties of undefined (reading 'compatibilityFlags') error when deploying to CF with start when i enable SPA mode with these settings:
// vite.config.ts
export default defineConfig({
plugins: [
...
cloudflare({ viteEnvironment: { name: 'ssr' } }),
tanstackStart({
spa: {
enabled: true,
},
}),
],
})
// vite.config.ts
export default defineConfig({
plugins: [
...
cloudflare({ viteEnvironment: { name: 'ssr' } }),
tanstackStart({
spa: {
enabled: true,
},
}),
],
})
reverting the commit makes it work again any ideas why this happens? Also noticed that ssr is set to true under the CF plugin as based on the deployement guide Could this be the reason? Any way to deploy start to CF with ssr set to false?
10 Replies
rare-sapphire
rare-sapphire2w ago
@Cloudflare (Partner) where does this error occur? locally?
other-emerald
other-emeraldOP2w ago
during the build on cf
rare-sapphire
rare-sapphire2w ago
so thats a good question for our cloudflare colleagues here then
other-emerald
other-emeraldOP2w ago
thanks, i'll also try crossposting on the cf server
ratty-blush
ratty-blush2w ago
SPA mode does prerendering and this doesn't currently work with Cloudflare because Start prerenders in Node. The error is because Node is trying to access a value that only exists in the Workers runtime. We are currently working together on a solution to make prerendering runtime agnostic so that routes will be prerendered in the target runtime.
other-emerald
other-emeraldOP2w ago
I see, thanks!
cloudy-cyan
cloudy-cyan5d ago
Any timeline on this? Are there any current workarounds?
rare-sapphire
rare-sapphire5d ago
its implemented already
cloudy-cyan
cloudy-cyan5d ago
Is there a deployment guide to Cloudflare pages?
extended-salmon
extended-salmon2d ago
We would advise you use Cloudflare workers to deploy Tanstack start rather than Pages. We have a npm create cloudflare starter generator that has a TanStack Start project bootstrap.

Did you find this page helpful?