Loading state while loader data is loading
Hi TanStack Start people,
I have a simple file route that uses a server function to return some data from my database - what is the best way to show a loading state while the function is executing, similar to
loading.tsx in Next.js?
I've tried defining a Route.pendingComponent but that doesn't seem to work - It just keeps the request loading for 2 seconds before returning the full value
Forgive me if the answer is clear, it's sometimes confusing for me whether I should be looking in the TanStack Start docs or the TanStack Router docs, both of which don't have very good searching
Here is my code with a Bun.sleep to simulate and see a good loading state:
2 Replies
equal-aqua•2mo ago
you would need to use deferred data loading
that means return the promise wrapped in e.g. an object
then
use or <Await> it in the componentambitious-aquaOP•2mo ago
okay I’ll give that a shot