npm @pinia/nuxt 0.0.5
🚀 Release 0.0.5

latest releases: 0.7.0, 0.6.1, 0.6.0...
3 years ago

BREAKING CHANGES

After taking a deeper look at what is necessary for SSR, a few things had to change:

  • Actions are no longer just functions, they must be attached to the store by being passed directly to createStore and they are called as methods of the store (e.g. store.reset())
  • createStore now takes an object instead of positional arguments
// before
export const useMainStore = createStore(
  // id
  'main',
  // state
  () => ({ counter: 0 }),
  // getters
  {
    doubleCount: state => state.counter * 2,
  }
)

export function reset() {
  const store = useMainStore()
  store.state.counter = 0
}
// now
export const useMainStore = createStore({
  id: 'main',
  state: () => ({ counter: 0 }),
  getters: {
    doubleCount: state => state.counter * 2,
  },
  actions: {
    reset() {
      this.state.counter = 0
    },
  },
})
  • feat: allow using getters in other getters (859eeb3)
  • feat: allow empty state option to make it easy to group stores (810e0f0)
  • feat: add nuxt module (4c0ef7a)
  • feat: allow passing the req to useStore (f250622)
  • fix: bind the actions to the store (5e262da)
  • feat: allow useStore to be called within a store (fdf6b45)
  • feat: handle SSR state hydration (2998d53)
  • feat: state hydration (db72247)
  • feat: export types, support state hydration (89996ed)

Don't miss a new nuxt release

NewReleases is sending notifications on new releases.