Menu

How do you structure feature-based React apps with Zustand, TanStack Query, providers, and business logic?

#reactjs#redditreactjs#domain#zustand#editor
Reading 0:00
15s threshold

Hey everyone! πŸ‘‹

I'm trying to establish a clean, reusable feature-based architecture for React/TypeScript apps , especially when using Zustand + TanStack Query .

I'm working on a visual editor that fetches documents from an API, initializes a Zustand editing session, and will eventually handle canvas state, selection, history, saving, etc.

I'm considering this structure:

features/editor/ β”œβ”€β”€ components/ β”œβ”€β”€ hooks/ β”œβ”€β”€ store/ β”‚ β”œβ”€β”€ editor-store.ts β”‚ β”œβ”€β”€ editor-store-provider.tsx β”‚ └── slices/ β”‚ β”œβ”€β”€ document-slice.ts β”‚ β”œβ”€β”€ selection-slice.ts β”‚ └── history-slice.ts β”œβ”€β”€ queries/ β”œβ”€β”€ domain/ ? β”œβ”€β”€ utils/ ? β”œβ”€β”€ lib/ ? └── services/ ?

I'd love to know how you handle a few things in production:

API / queries: Where do raw API functions go? Do you separate them from TanStack Query options/hooks? Do you organize queries by feature or shared domain?

Zustand: Do you keep providers alongside stores?…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.