T
TanStack3mo ago
broad-brown

SPA mode when deployed with SST

Has anyone used tanstack start in SPA mode when deployed in SST? I have tried to deploy with spa: { enabled: true } but the deployment hangs after Client and Server bundles for TanStack Start have been successfully built. Also I have tried to disable prerender but it is still attempting to prerender the shell
tanstackStart({
customViteReactPlugin: true,
target: 'aws-lambda',
spa: {
enabled: true,
prerender: {
enabled: false,
},
},
}),
tanstackStart({
customViteReactPlugin: true,
target: 'aws-lambda',
spa: {
enabled: true,
prerender: {
enabled: false,
},
},
}),
✔ Generated public .output/public nitro 3:37:26 PM
[prerender] Prerendering pages...
[prerender] Concurrency: 14
[prerender] Crawling: /
✔ Generated public .output/public nitro 3:37:26 PM
[prerender] Prerendering pages...
[prerender] Concurrency: 14
[prerender] Crawling: /
I have a loader on my / route which I want to be run on the client, but not when creating the SPA shell. Should I just do
const isShell = useRouter().isShell()

if (isShell) return <div>Loading...</div>
const isShell = useRouter().isShell()

if (isShell) return <div>Loading...</div>
or something along them lines?
9 Replies
national-gold
national-gold3mo ago
SPA mode needs the shell to be prerendered
I have a loader on my / route
do you mean the __root route? or the /index route
broad-brown
broad-brownOP3mo ago
Ahh I see so it just prerenders the routes/__root.tsx, not routes/index.tsx ? I currently have a loader on both but I think with it running in SPA mode I can remove the one on __root
national-gold
national-gold3mo ago
it also renders /index but it does not use that data in the shell you can set a different mask path for prerendering the shell
broad-brown
broad-brownOP3mo ago
@Manuel Schiller my understanding was that in SPA mode the server would only be used for server functions/api routes. Is this incorrect? I'm looking in the .output/server file and I can see that there is react code in there. I'm wanting to try and keep the server as small as possible so that when it is deployed to a lambda it will be as fast as possible.
national-gold
national-gold3mo ago
this is correct, there is no server rendering at runtime the build just does not respect that yet can you please create a github issue for this so we can track this properly?
broad-brown
broad-brownOP3mo ago
Ahh sweet. Yeah will do! Thanks for your help
broad-brown
broad-brownOP3mo ago
GitHub
SPA mode server build contains unnecessary SSR code · Issue #5059 ...
Which project does this relate to? Start Describe the bug When running tanstack start in SPA mode, the server build contains SSR code. Your Example Website or App Steps to Reproduce the Bug or Issu...
conscious-sapphire
conscious-sapphire3mo ago
can we make this configurable actually like it would be great if we can support creating a _shell file while still having SSR it's perfect for my use-case of SSR -> SPA via a service worker
national-gold
national-gold3mo ago
could be done yes

Did you find this page helpful?