Vue · Senior · Question 30 of 75

When is a module-level composable singleton enough instead of Pinia?

const state = reactive({ items: [] });
export function useCart() { return { items: readonly(state.items), add } }

Explanation

Pinia adds devtools time travel, plugins, HMR, a testing helper and per-request instances for SSR. For SSR, module singletons are a state-pollution bug.

Further reading

Problem with a question

Vue · Senior · question 30

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