T
TanStack4w ago
exotic-emerald

@tanstack/react-router streaming ssr

Hello, Im trying out this example https://github.com/TanStack/router/blob/main/examples/react/basic-ssr-streaming-file-based/vite.config.ts my question is it necessary to build for both client and server? and why is this happening?
2 Replies
other-emerald
other-emerald4w ago
from the docs: "Server Side Rendering (SSR) is the process of rendering a component on the server and sending the HTML markup to the client. The client then hydrates the markup into a fully interactive component." In order to do this we need to have a specific entry point for the server side rendering and then a client bundle that takes over once the hydration has completed. We therefore have 2 sets of code that needs to be built and segregated: One that includes the necessary server instructions to render the html on the server and the second that is built specifically for client side rendering.
other-emerald
other-emerald4w ago
as to your second question have a look at the pre-loading section on the docs (https://tanstack.com/router/latest/docs/framework/react/guide/preloading) it might help to clear it up, what your seeing is the fetch queries executing ahead of time to reduce loading time when the user clicks on a post
Preloading | TanStack Router React Docs
Preloading in TanStack Router is a way to load a route before the user actually navigates to it. This is useful for routes that are likely to be visited by the user next. For example, if you have a li...

Did you find this page helpful?