Pinia · PINIA0007

Return 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.
PINIA0007vite-doctor/piniastoreswarnNo fix

Run this rule

pnpm vite-doctor . --rules pinia/stores/no-unreturned-setup-state

Why it matters

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.

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 }
})
Copyright © 2026