
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
vuex-models
Advanced tools
This package is aims to simplify v-model usage with your vuex state, by providing getter/action/mutation/state generator and mapper, that generates v-model compatible computed properties.
It is compatible with Vue 2.x
Just use npm:
npm i --save vuex-models
Using vuex-models is a dead simple - first you need to generate store fields like this:
// your imports
import { genVuexModels } from "vuex-models";
// Vue.use(Vuex), etc
/*
First argument is an array of generated field names
Second optional argument - state attribute name,
where generated fields will be stored their states
*/
// models with initial state values
const models = genVuexModels(
{
foo: "defaultValueForFoo",
bar: "defaultValueForBar",
},
"customField"
); // By default: Vxm
const store = new Vuex.Store({
...models,
});
/*
Vuex state becomes to:
{
customField: {
foo: 'defaultValueForFoo',
bar: 'defaultValueForBar'
}
}
*/
export default store;
Then, in your vue components you can map computed properties by using mapVuexModels:
import { mapVuexModels } from "vuex-models";
export default {
computed: {
/*
creating computed properties:
foo: {
get () { return this.$store.getters.autogeneratedGetterFoo },
set (val) { this.$store.dispatch('autogeneratedAction', val) }
}
so, from now, you can safely use `foo` in v-model directives
*/
...mapVuexModels(["foo", "bar"]),
},
};
Also you can use vuex-models for namespaced vuex modules. All you need is to pass second argument to mapVuexModels with namespace name:
// for example we have store module namespaced with 'MyNamespacedModule'
/*
const store = new Vuex.Store({
modules: {
MyNamespacedModule: {
namespaced: true,
...genVuexModels({
foo: 'value'
})
}
}
})
*/
export default {
computed: {
...mapVuexModels(["foo"], "MyNamespacedModule"),
},
};
Like vuex mappers, mapVuexModels supports properties renaming:
export default {
computed: {
// this.myFoo responds to store.foo model
...mapVuexModels({
myFoo: "foo",
}),
},
};
FAQs
Simple two-way data binding between vue components and vuex store
The npm package vuex-models receives a total of 2 weekly downloads. As such, vuex-models popularity was classified as not popular.
We found that vuex-models demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.