Skip to content

Instantly share code, notes, and snippets.

@devmnj
Created November 26, 2021 17:22
Show Gist options
  • Select an option

  • Save devmnj/200fead77484356457a272eec1ad35f9 to your computer and use it in GitHub Desktop.

Select an option

Save devmnj/200fead77484356457a272eec1ad35f9 to your computer and use it in GitHub Desktop.
Nuxt3 Pinia Store example [typescript]
import { defineStore,acceptHMRUpdate } from 'pinia'
export const useStore = defineStore('storeId', {
// arrow function recommended for full type inference
state: () => {
return {
// all these properties will have their type inferred automatically
count: 0,
}
},
})
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useStore, import.meta.hot))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment