How to configure tanstack start to completely opt out of SSR while keeping server functions?
I built my project from scratch using the docs https://tanstack.com/start/latest/docs/framework/react/build-from-scratch.
What adjustments should i make to achieve desired behaviour?
19 Replies
adverse-sapphire•8mo ago
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 optionsquickest-silverOP•8mo ago
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

adverse-sapphire•8mo ago
what happens if you try this?
quickest-silverOP•8mo ago
I see this in console and a blank page which take 3 seconds to load

quickest-silverOP•8mo ago
It seems like loader function runs on the server and blocks for some reason
Even with disabled SSR
adverse-sapphire•8mo ago
can you provide this as a git repo?
quickest-silverOP•8mo ago
Yes, sure
quickest-silverOP•8mo ago
GitHub
GitHub - manylovv/tanstack-start-question
Contribute to manylovv/tanstack-start-question development by creating an account on GitHub.
quickest-silverOP•8mo ago
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

adverse-sapphire•8mo ago
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
quickest-silverOP•8mo ago
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
adverse-sapphire•8mo ago
to make what work?
quickest-silverOP•8mo ago
to make all requests from the client
adverse-sapphire•8mo ago
dont use loaders
intead
useQuery
from the componentsquickest-silverOP•8mo ago
Thank you
adverse-sapphire•8mo ago
so this works as expected on a prod build
but not in dev
i guess this is caused by the
adverse-sapphire•8mo ago
we have an issue open for this here: https://github.com/TanStack/router/issues/3328
GitHub
HMR issue when refresh-runtime hasn't finished initializing · Issue...
Which project does this relate to? Start Describe the bug First of all, I would like to say thank you for HMR support in Start — it's great. Today I found a new issue with @vite/plugin-react er...
quickest-silverOP•8mo ago
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.
quickest-silverOP•8mo ago
here is the code
