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 } }- ✓Correct answer: In a client-only app with simple shared state, when you don't need devtools, plugins or SSR safety
- 2Never; singletons don't work in Vue
- 3Always; Pinia offers nothing extra
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.