T
TanStack8mo ago
quickest-silver

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
adverse-sapphire8mo 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 options
quickest-silver
quickest-silverOP8mo 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
No description
adverse-sapphire
adverse-sapphire8mo ago
what happens if you try this?
quickest-silver
quickest-silverOP8mo ago
I see this in console and a blank page which take 3 seconds to load
No description
quickest-silver
quickest-silverOP8mo ago
It seems like loader function runs on the server and blocks for some reason Even with disabled SSR
adverse-sapphire
adverse-sapphire8mo ago
can you provide this as a git repo?
quickest-silver
quickest-silverOP8mo ago
Yes, sure
quickest-silver
quickest-silverOP8mo ago
GitHub
GitHub - manylovv/tanstack-start-question
Contribute to manylovv/tanstack-start-question development by creating an account on GitHub.
quickest-silver
quickest-silverOP8mo 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
No description
adverse-sapphire
adverse-sapphire8mo 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-silver
quickest-silverOP8mo 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
adverse-sapphire8mo ago
to make what work?
quickest-silver
quickest-silverOP8mo ago
to make all requests from the client
adverse-sapphire
adverse-sapphire8mo ago
dont use loaders intead useQuery from the components
quickest-silver
quickest-silverOP8mo ago
Thank you
adverse-sapphire
adverse-sapphire8mo ago
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
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
adverse-sapphire
adverse-sapphire8mo 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-silver
quickest-silverOP8mo 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-silver
quickest-silverOP8mo ago
here is the code
No description

Did you find this page helpful?