root.tsx vs main.tsx
How do I decide what to put in
src/main.tsx
vs src/routes/__root.tsx
?
I am using Zustand, TS Query and Router, and ShadCN. I don't know where I should setup Zustand and TS Query or where I should put my sidebar.3 Replies
like-gold•4mo ago
Create your ts query and zustand providers and create them alongside the router in
main
or wherever you call createRouter
Your sidebar id image goes in root or a layout routelike-gold•4mo ago
React TanStack Router Basic React Query File Based Example | TanSta...
An example showing how to implement Basic React Query File Based in React using TanStack Router.
genetic-orange•4mo ago
the difference is basically: if you need access to things in the
loader
, you need to add it to the router context, and that happens in createRouter
, which usually happens in main
. So that's why the queryClient
is created there.
If you just need to create a context provider that's available globally, I'd put that in the root route