PINIA is a new State Manager Tool for VueJS. This is a mindmap about PINIA

Get Started. It's Free
or sign up with your email address
PINIA by Mind Map: PINIA

1. Basics

1.1. What is PINIA?

1.1.1. It is a State Management Solution Uses the new reactivity system in Vue 3

1.1.2. Implemented by Eduardo San Martin Morote Vue Core Team Member Who also created the Vue Router

1.1.3. Officially Recommended

1.1.4. Officially Replaced Vuex

1.2. What is the purpose of it?

1.2.1. Share data between components

1.2.2. Reduce the complexity of the components communication Reduce data emitting to parents Reduce props passing to children

1.2.3. Introduce a global state that is sharable between components

1.2.4. Provide a single state and pass out to components

1.2.5. Provide mechanism to components to mutate

1.3. When to introduce PINIA?

1.3.1. When you work on medium or large projects

1.3.2. Above 10 components

1.3.3. When the project projects growth

1.4. Why PINIA?

1.4.1. Intuitive

1.4.2. Type Safe autocompletion

1.4.3. Devtools Support Hooks into devtools for enhanced development experience View and Alter states directly from devtools U can use timeline to view mutation to the store overtime

1.4.4. Extensible Transactions Local Storage Syncronization

1.4.5. Modular Options for code split by stores Multiple stores creation

1.4.6. Grouping of state changes

1.4.7. Lightweight By Design 1KB

2. Vuex vs Pinia

2.1. Install

2.1.1. Pinia

2.1.2. Vuex

2.2. Setup

2.2.1. Pinia

2.2.2. Vuex Global Object

2.3. Usage

2.3.1. Vuex Example

2.3.2. Pinia Example

2.4. Performance

2.4.1. Pinia and Vuex both fast Pinia can be faster in cases performance boost can be attributed to Pinia’s size. Pinia is extremely lightweight. It is around 1KB.

2.4.2. some features like time traveling and editing are still not supported because Vue devtools doesn’t expose the necessary APIs

2.5. Author opinion who also participate in Vuex development

2.5.1. Pinia tries to stay as close to Vuex’s philosophy as possible. It was designed to test out a proposal for the next iteration of Vuex and it was a success as we currently have an open RFC for Vuex 5 with an API very similar to the one used by Pinia. My personal intention with this project is to redesign the experience of using a global Store while keeping the approachable philosophy of Vue. I keep the API of Pinia as close as Vuex as it keeps moving forward to make it easy for people to migrate to Vuex or to even fusion both projects (under Vuex) in the future.

2.6. Pros&Cons

2.6.1. Pinia Pro Full TypeScript support: adding TypeScript is easy compared to adding TypeScript in Vuex Extremely lightweight (weighing around 1KB) The store’s actions are dispatched as regular function calls rather than using the dispatch method or MapAction helper function, which is common in Vuex Has support for multiple stores Has support for Vue devtools, SSR, and webpack code splitting Cons No support for debugging features like time traveling and editing

2.6.2. Vuex Pro Supports debugging features like time traveling and editing Suitable for large-scale and high complexity Vue.js projects Cons As of Vue 3, the getter’s result is not cached as the computed property does Vuex 4 has some problems associated with type safety