Vue · Senior · Question 43 of 75
What can a Pinia plugin do?
pinia.use(({ store }) => {
store.$subscribe((mutation, state) => localStorage.setItem(store.$id, JSON.stringify(state)));
});- ✓Correct answer: Add properties or options to every store and react to state changes and actions (e.g. persistence, logging)
- 2Replace Vue's reactivity system
- 3Register routes
Explanation
Plugins run for every store when it is first used. Popular plugins add persistence; typing new properties is done with PiniaCustomProperties augmentation.