Pinia · Stores
PINIA0007Return every ref and reactive() a setup store changes
Report ref() and reactive() state that a setup store's functions write but its setup function does not return.
vite-doctor/piniastoreswarnNo fix
Why it happens
Pinia builds a setup store's state from the refs and reactive objects the setup function returns, and its docs say you must return all state properties. State left out is missing from store.$state, $patch(), $reset() in plugins, Devtools, and the payload that hydrates the store after server-side rendering, so the client starts from the initial value and anything computed from it can differ from the server.
Fix
Return the ref or reactive object from the setup function so Pinia can manage it.
Example
Return the state the actions write
Before
export const useSearchStore = defineStore('search', () => {
const query = ref('')
const results = computed(() => search(query.value))
function setQuery(value: string) {
query.value = value
}
return { results, setQuery }
})
After
export const useSearchStore = defineStore('search', () => {
const query = ref('')
const results = computed(() => search(query.value))
function setQuery(value: string) {
query.value = value
}
return { query, results, setQuery }
})
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --rules pinia/stores/no-unreturned-setup-state