#How to configure tanstack start to completely opt out of SSR while keeping server functions?

28 messages · Page 1 of 1 (latest)

reef hare
naive wave
#

as of now you cannot completely disable SSR

#

root route will currently be SSRed no matter what

#

we have a SPA mode for start planned though

#

for all other routes you can disable SSR via defaultSsr: false in router options

reef hare
#

Can I return a promise from loader function with ssr disabled, using server function just as rpc called from the client, and than await it on the client? coundn't figure out how to get this to work

naive wave
#

what happens if you try this?

reef hare
#

I see this in console and a blank page which take 3 seconds to load

#

It seems like loader function runs on the server and blocks for some reason

#

Even with disabled SSR

naive wave
#

can you provide this as a git repo?

reef hare
#

Yes, sure

#

One more thing, even if i await the promise it still blocks the page. I thought that with no ssr, loader would run on the client and make an http request

naive wave
#

no, loader is still executed on the server

#

that would only happen when we have the SPA mode in the future

#

"ssr: false" currently just means that nothing is RENDERED on the server, but the loaders still run there

reef hare
#

Okay, got it, thanks! Is there some workarounds to make it work now? Using tanstack query and using server fn as query function should be fine

naive wave
#

to make what work?

reef hare
#

to make all requests from the client

naive wave
#

dont use loaders

#

intead useQuery from the components

reef hare
#

Thank you

naive wave
#

so this works as expected on a prod build

#

but not in dev

#

i guess this is caused by the

Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201
    at __root.tsx:1:65
reef hare
#

Also, I have reenabled the SSR (rolled back to defaults) and streaming works as expected, but the onClick function on button doesn't work at all. And the same error appears in the console

Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.