Skip to content

Report a problem:

Problems can be reported via Microsoft Teams in your team channel within the "IT - Codey" team.

Please include the following information:

Report type:
Docs problem report a bug instead →
Path:
/vnext/cookbook/the-stack/state-management/
Message:

DESCRIBE THE PROBLEM BEFORE SUBMITTING TO CODEY

State Management

Note

Need help crafting the state approach for your application?

Reach out to one of the Codey team members, we're happy to help!

State management in Vue can be approached on three levels, depending on the scope and lifecycle of the data and complexity you are working with:

LevelDescriptionTypical Use CaseRecommended Tooling
Component StateState lives only inside a single component and is not shared.Local form data, UI toggles, isolated logic.Vue refs/reactive, component props, libraries like VeeValidate for validation.
Application / Instance StateState is shared between multiple components within the app instance.Authentication, user preferences, app-wide settings.Pinia (structured/global), or Vue Composables (flexible, can be instance or global).
Server State & Client-Side CachingState represents remote data fetched from an API. Must handle loading, errors, caching, and updates.Lists of customers, products, orders, or any backend-driven entity.Vue Query (default choice), or Pinia/Composables for edge cases where full control is required.

Guidance: When to Use What

  • Start as local as possible: keep state in the component if it does not need to be shared.
  • If multiple components need to access or update the same state → move it to application state via Pinia or composables.
  • If state comes from an API and requires caching, invalidation, or syncing with a backend → use Vue Query.

state-management-flow-diagram

Report a problem:

Problems can be reported via Microsoft Teams in your team channel within the "IT - Codey" team.

Please include the following information:

Report type:
Docs problem report a bug instead →
Path:
/vnext/cookbook/the-stack/state-management/
Message:

DESCRIBE THE PROBLEM BEFORE SUBMITTING TO CODEY

Last updated: