T
TanStack•11mo ago
optimistic-gold

Does Start work with Router's defer() out of the box with SSR?

EDIT: I thought I had been testing on node as well as bun, but I think something was autodetecting bun and starting a worker/child process with bun automatically even when running the vinxi dev command with npm. After wiping bun.lockb and doing a fresh packages install, then running with npm, things are streaming correctly. Then running with bun run --bun dev, I get the blocking behaviour back. So something streaming-related is broken when running under bun. Should start work with router's defer() and serverFns when SSR is enabled? I'm trying to render a sidebar in my __root that displays some non-critical async data, so I followed router docs for defer() but it seems as though Start's SSR is not streaming the response to the client until the deferred promise has resolved Context: Running locally on dev server, Windows, same behaviour on node (I thought I was testing under node, but something was autodetecting my bun lockfile and "helpfully" using bun despite running with npm) and bun. Tested on tanstack versions 1.74.0 and 1.78.3
6 Replies
optimistic-gold
optimistic-goldOP•11mo ago
Interestingly the "deferred" tab on the Basic example linked in the Start docs is erroring 😅 (though that's not what I'm experiencing on my simple app) https://tanstack.com/router/latest/docs/framework/react/examples/start-basic Even if I move the deferred data loading out of __root (in case it's handled specially 🤷 ) and into e.g the / index route, the server still isn't responding until the deferred promise has resolved Update: Seems it's related to running under bun, possibly limited to Windows but I can't test another platform easily rn.
optimistic-gold
optimistic-goldOP•11mo ago
Could potentially be related to this bun issue https://github.com/oven-sh/bun/issues/13696
GitHub
Streaming http responses are delayed until more chunks arrive · Iss...
What version of Bun is running? 1.1.26+0a37423ba What platform is your computer? Linux 5.15.0-119-generic x86_64 x86_64 What steps can reproduce the bug? Create a new project following the official...
xenial-black
xenial-black•11mo ago
Hey, I'm still learning TanStack Start, but take a look at useSuspenseQuery, might be what you need
xenial-black
xenial-black•11mo ago
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
xenial-black
xenial-black•11mo ago
The "deferred" tab on this example (start-basic-react-query) uses useSuspenseQuery instead of defer()
xenial-black
xenial-black•11mo ago
Netlify
YouTube
An Early Glimpse of TanStack Start
TanStack Start is a fresh take on full-stack React development by the same creators of TanStack Query and TanStack Router. With an emphasis on type safety, developer experience, and productivity, Start marks a balance of intuitive tools and powerful primitives. Join us as we explore its early pre-release APIs and patterns and how they can improv...

Did you find this page helpful?