Skip to main content

React Prompt to Plan State Management Architecture (Zustand, RTK, Query)

Design the optimal React state architecture, choosing between Context, Zustand, Jotai, Redux Toolkit and TanStack Query.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt designs the state management architecture for a React app, recommending the right combination of tools rather than forcing one library to do everything. It evaluates React Context, Zustand, Jotai, Redux Toolkit, and TanStack Query against your app's needs, then explains for each state category which tool to use and why, with folder structure, store setup, custom hooks, devtools, persistence, and a migration path from your current solution — plus a data-flow diagram.

The variables describe your situation so the recommendation fits. [app_type] and [complexity_level] set scale, [data_types] lists the kinds of state you hold (session, server data, UI state, forms, notifications), [realtime_needs] and [offline_required] flag WebSocket and offline concerns, and [current_solution] is what you're migrating from. The key insight the prompt encodes is separating server cache from client state: TanStack Query owns server data, while Zustand or Context owns UI state. Pressure-testing that split and the migration path before committing prevents the common mess of one over-stretched store.

When to use it

  • Choosing state tools for a new non-trivial React app before writing stores
  • Untangling an app where one Redux store has absorbed every kind of state
  • Deciding where server cache ends and client UI state begins
  • Planning a migration off Redux thunks to a lighter combination
  • Designing persistence and offline-read strategy deliberately
  • Documenting a data-flow diagram so the team shares one mental model

Example output

You get a written recommendation mapping each of your [data_types] to a specific tool, with rationale, plus folder structure, example store setup, custom hooks, devtools configuration, and a persistence strategy. There's a concrete migration path from [current_solution] and a data-flow diagram showing how state moves through the app. Rather than "use Zustand," it justifies the split — server data on TanStack Query, UI state on Zustand or Context — so the choices hold up as the app grows.

Pro tips

  • List [data_types] honestly and granularly; lumping server data in with UI state is exactly the mistake this prompt exists to prevent
  • Set [complexity_level] realistically — over-stating it invites heavier tooling than a medium app needs
  • Be specific about [realtime_needs]; WebSocket-driven state has different caching implications than polled data
  • Name your actual [current_solution] so the migration path is concrete rather than generic advice
  • Treat the recommendation as a decision to debate, not a verdict — the value is in the rationale, which you can challenge
  • Resist adopting every tool it suggests at once; migrate one state category at a time using the provided path

Frequently Asked Questions

Why not just use one state library for everything?
Forcing a single tool to handle server cache, UI state, and forms is the recurring mistake this prompt targets. Server data and client state have different lifecycles, so separating them keeps the codebase clean as the app grows rather than entangling unrelated concerns.
Does it tell me to replace my current setup entirely?
Not necessarily. It provides a migration path from your current solution, which you can apply incrementally one state category at a time. The point is a deliberate split, not a forced rewrite of everything you already have.
How does it decide between Zustand, Jotai, and Context?
It weighs your app complexity, data types, and real-time needs against each tool's strengths. The recommendation includes the reasoning, so you can challenge it, but generally lighter UI state suits Context or Zustand while atomized state suits Jotai.
What does it recommend for server data specifically?
It typically assigns server data to TanStack Query, which handles caching, revalidation, and request deduplication. Keeping that out of your client state store is the central recommendation, since mixing them is what makes large React apps hard to reason about.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in React & Next.js Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support