T
TanStackβ€’7d ago
tame-yellow

Combine SSR and Static Prerendering in the same route?

Hey everyone, I wonder how static prerendering works. I have an app where I use all the features from Router+Start. several pages, nested routes, dynamic segments, data loading, prefetching queries in loader, integration with tanstack query, suspense boundary, ... etc. When I turn on prerendering for most of the pages, what actually happens? From top of my head I see 3 possible ways: 1. TanStack just throws those files in some output folder, but actually does not make use of them when using the server. So we need to take them and upload somewhere and integrate with othere dynamic pages. 2. TanStack servers prerendered pages form the server to the user. The page contains build-time data. But hydrates the page after on a client and allows to refetch data from a client. 3. TanStack prerenders only unsuspended parts of the page with fallbacks. And server streams in the suspended part on reqest-time. Like partial prerendering in Next.js Or does it work differently? AFAIK there is nothing that specific in the docs. Thank you for helping to understand. πŸ™‚
2 Replies
metropolitan-bronze
metropolitan-bronzeβ€’7d ago
I haven't tried it. But maybe you can enable prerendering, put your fetching data on loaders and wrap the components that have useSuspenseQuery with suspense. That way it should prerender everything except the ones in the suspense boundary, which will get the data through streaming. That's just an idea, hope it makes sense.
typical-coral
typical-coralβ€’7d ago
TanStack Start runs the page at build time and stores the output. If a user makes a direct request to that page, it serves the prerendered content. If you have dynamic content but still want the whole page prerendered, for now you have to make that part client-side, similar to how it works in Next.js ≀15, since PPR (Partial Prerendering) isn’t available yet. For things like ISR, SWR, etc., you need to rely on cache headers + CDN or a server like Nginx. Alternatively, you can implement your own ISR logic by using something like srvx, unStorage, or any storage solution inside your HTTP Start handler.

Did you find this page helpful?