Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/typed-vuex. 馃彟 A typed store accessor for vanilla Vuex. typed-vuex.roe.dev
Something went wrong. Try again.
README.md
Introduction #
Nuxt Typed Vuex is made up of two packages:
typed-vuex- a typed store accessor with helper functions, with no Nuxt dependenciesnuxt-typed-vuex- a Nuxt module that auto-injects this accessor throughout your project
Why another package? #
Typing vanilla Vuex is complicated. Many people choose a class-based approach with Typescript decorators. However, this can cause issues, including:
- incompatibilities with Nuxt
- not being able to access
this.$axiosor the app/store instance from within actions - too much boilerplate for accessors (such as initialising them in every component that uses them)
- slower performance
There are not many alternatives, and although Vuex provides limited type definitions for the store itself, it's complicated to access it in a type-safe way.
nuxt-typed-vuex was developed to address this problem, allowing you to write your store using vanilla Vuex code, and access it using a high-performance, strongly-typed accessor.


Alternatives #
If you would prefer a class-based approach, good options include vuex-module-decorators and vuex-class-component.