What is the tanstack way of doing loading? (Example: Next.js has loading.tsx)
Is there a way i can add a loader to a specific road that does server-side loader?
4 Replies
harsh-harlequin•4mo ago
are you looking for deferred loading?
you can use Await or just React.use. this will suspend your route component and then should cause the pending component to be rendered
continuing-cyanOP•4mo ago
aha thanks! 😄
Yeah, deferred loading 🙂
ambitious-aqua•4mo ago
Yeah, use pending component: https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#pendingcomponent-property
RouteOptions type | TanStack Router React Docs
The RouteOptions type is used to describe the options that can be used when creating a route. RouteOptions properties The RouteOptions type accepts an object with the following properties: getParentRo...
ambitious-aqua•4mo ago
And useSuspenseQuery should use it properly too