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)));
});

Explanation

Plugins run for every store when it is first used. Popular plugins add persistence; typing new properties is done with PiniaCustomProperties augmentation.

Further reading

Problem with a question

Vue · Senior · question 43

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz