storeToRefs

storeToRefs extracts the state and getters of a Pinia store as reactive refs. Without it, breaking up the store with destructuring loses reactivity. Actions, which are simple functions, can be destructured directly from the store.

Example

const store = useCompteur()
const { n } = storeToRefs(store)
const { incrementer } = store

Related concepts

The whole glossary