Mobile State Management
Purpose
Assign each piece of state to the right owner and tool, so the app uses the lightest approach that fits — not one global store for everything. Coordinates with mobile-server-state (server data) and mobile-forms (form state).
When to Use
- When planning a screen/feature's data and interaction model.
- When an app over-uses (or lacks) a shared store.
- Not as a mandate to add a global store to every app.
Inputs
- The feature's data: what's ephemeral, shared, fetched, persisted, or navigation-driven.
- Approved stack (which state tools are available).
Discovery Questions
- Is this value used by one component, a subtree, or app-wide?
- Does it come from the server (then it's server state)?
- Must it survive app restarts (persisted)?
- Is it really navigation state (route params, focused tab)?
Responsibilities
Classify each value into the right category and choose accordingly:
- Local component state —
useState/useReducer for values one component owns.
- Form state — a form library (
mobile-forms), not global state.
- Shared client state — Context for low-frequency shared UI state; Redux Toolkit or Zustand for genuinely app-wide, frequently-updated client state.
- Server state — a server-cache library (
mobile-server-state: RTK Query / TanStack Query), not a manual global store.
- Persisted state — secure/async storage with a clear rehydration path (
mobile-secure-storage for sensitive data).
- Navigation state — owned by the navigator (
mobile-navigation), via params/route, not duplicated into a store.
Required Workflow
- List the feature's state values.
- Classify each into one of the six categories.
- Pick the lightest tool per category.
- Keep server state out of client stores; keep form state in the form.
- Record the state-ownership decisions.
Decision Rules
- Do not put every value in Redux/Zustand. Reach for a global store only for genuinely app-wide, frequently-changing client state.
- Server data → server-cache library, not a hand-rolled global store.
- Form state → form library; navigation state → navigator; persisted → storage.
- Prefer Context over a store for simple, low-frequency shared UI state; prefer a store when Context would cause broad re-renders.
Rules
- One category per value; don't duplicate the same state across owners.
- Keep client and server state separate.
- Choose from the approved stack; justify any store addition.
Anti-Patterns
- "Everything in Redux/Zustand."
- Storing server data manually instead of using a cache library.
- Putting form state or route params into a global store.
- Context for high-frequency state (re-render storms).
Validation Checklist
Definition of Done
A recorded state-ownership map: each value assigned to local / form / shared-client / server / persisted / navigation with the chosen tool — no over-centralization, client and server state separated.
Related Skills
mobile-server-state, mobile-forms, mobile-navigation, mobile-secure-storage, mobile-performance, ../../stack-recommendation.
Related Knowledge
../../../knowledge/ (data model, state decisions).
Related References
../../../references/mobile/state/ when populated.
Context Loading Guidance
- Requires: the feature's state values, approved state tools.
- Does not require: unrelated screens, the full mobile skill set, unrelated references.
- May load:
mobile-server-state, mobile-forms for their categories.
- Stop when: the state-ownership map is recorded.
Token Efficiency Guidance
Reason from the value list, not the whole screen tree. Delegate server/form state to their skills instead of restating them.
1---2name: mobile-state-management3description: Use to decide where each piece of state lives — local component state, form state, shared client state, server state, persisted state, or navigation state. Prevents dumping everything into Redux/Zustand. Chooses the lightest tool that fits each category.4---56# Mobile State Management78## Purpose910Assign each piece of state to the right owner and tool, so the app uses the lightest approach that fits — not one global store for everything. Coordinates with `mobile-server-state` (server data) and `mobile-forms` (form state).1112## When to Use1314- When planning a screen/feature's data and interaction model.15- When an app over-uses (or lacks) a shared store.16- **Not** as a mandate to add a global store to every app.1718## Inputs1920- The feature's data: what's ephemeral, shared, fetched, persisted, or navigation-driven.21- Approved stack (which state tools are available).2223## Discovery Questions2425- Is this value used by one component, a subtree, or app-wide?26- Does it come from the server (then it's server state)?27- Must it survive app restarts (persisted)?28- Is it really navigation state (route params, focused tab)?2930## Responsibilities3132Classify each value into the right category and choose accordingly:33- **Local component state** — `useState`/`useReducer` for values one component owns.34- **Form state** — a form library (`mobile-forms`), not global state.35- **Shared client state** — Context for low-frequency shared UI state; Redux Toolkit or Zustand for genuinely app-wide, frequently-updated client state.36- **Server state** — a server-cache library (`mobile-server-state`: RTK Query / TanStack Query), **not** a manual global store.37- **Persisted state** — secure/async storage with a clear rehydration path (`mobile-secure-storage` for sensitive data).38- **Navigation state** — owned by the navigator (`mobile-navigation`), via params/route, not duplicated into a store.3940## Required Workflow41421. List the feature's state values.432. Classify each into one of the six categories.443. Pick the lightest tool per category.454. Keep server state out of client stores; keep form state in the form.465. Record the state-ownership decisions.4748## Decision Rules4950- **Do not put every value in Redux/Zustand.** Reach for a global store only for genuinely app-wide, frequently-changing client state.51- Server data → server-cache library, not a hand-rolled global store.52- Form state → form library; navigation state → navigator; persisted → storage.53- Prefer Context over a store for simple, low-frequency shared UI state; prefer a store when Context would cause broad re-renders.5455## Rules5657- One category per value; don't duplicate the same state across owners.58- Keep client and server state separate.59- Choose from the approved stack; justify any store addition.6061## Anti-Patterns6263- "Everything in Redux/Zustand."64- Storing server data manually instead of using a cache library.65- Putting form state or route params into a global store.66- Context for high-frequency state (re-render storms).6768## Validation Checklist6970- [ ] Each value classified into one of the six categories.71- [ ] Lightest fitting tool chosen per category.72- [ ] Server state handled by a cache library, not a store.73- [ ] Form/navigation/persisted state owned correctly.74- [ ] Any global-store use justified.7576## Definition of Done7778A recorded state-ownership map: each value assigned to local / form / shared-client / server / persisted / navigation with the chosen tool — no over-centralization, client and server state separated.7980## Related Skills8182`mobile-server-state`, `mobile-forms`, `mobile-navigation`, `mobile-secure-storage`, `mobile-performance`, `../../stack-recommendation`.8384## Related Knowledge8586`../../../knowledge/` (data model, state decisions).8788## Related References8990`../../../references/mobile/state/` when populated.9192## Context Loading Guidance9394- **Requires:** the feature's state values, approved state tools.95- **Does not require:** unrelated screens, the full mobile skill set, unrelated references.96- **May load:** `mobile-server-state`, `mobile-forms` for their categories.97- **Stop when:** the state-ownership map is recorded.9899## Token Efficiency Guidance100101Reason from the value list, not the whole screen tree. Delegate server/form state to their skills instead of restating them.