Everything You Need to Know About Vuex Plugins

A while ago, we wrote a beginner’s guide to Vue and Vuex and explained both the basics of Vue as a progressive JavaScript framework and Vuex as the official state management solution.

As you probably know, Vuex serves as a single source of truth given the fact all components are consolidated into one global location. It is a centralized library that enables developers to have a clean top overview of every segment. Vuex relies on Actions, Mutations, and Getters to provide a full state management pattern.

When you bear in mind all its characteristics and the way Vuex influences the coding process, it’s safe to say that it provides a great way of simultaneous front-end and back-end development.

Today, we’re going to take a closer look at Vuex plugins and when they are useful. So, if you are well acquainted with Vue.js and Vuex and you want to learn more about Vuex plugins and how we at Share IT use them, keep reading.

What Are Vuex Plugins?


  • Vue plugins (they add global level functionality or new kinds of components to Vue)
  • Vue-cli plugins (they modify the build system and add functionality to webpack/cli-service)
  • Vuex plugins (they add functionality to Vuex by getting access to all mutation hooks)

Vuex plugins is an option that exposes hooks to each mutation. A plugin is a function that receives the store as the only argument, which makes it very useful. There are a lot of Vuex plugins out there made by other developers and they are free to use.

Vuex plugins cannot directly mutate states, they can only commit mutations. By committing mutations, it’s possible to use a plugin to sync a data source to the store.

To summarize, Vuex plugins are triggered on every mutation, they receive name and payload of the mutation, and they receive a new state of the store after the mutation.

When building Vuex plugins, developers need to consider what to do when a mutation occurs, are actions different for different mutations, is another mutation needed during the process, etc.

Now, let’s move on to examine how plugins differ from mixins.

Plugins vs. Mixins: What is the Difference?


Mixins are much like extended components, but they also add functionality to existing components. A mixin in a plugin is global, which means it is applied to all components. Whether a developer chooses a plugin or a mixin depends on whether or not the introduced functionality makes sense only to some components or to all of them.

You could say that mixins provide much-needed flexibility for distributing reusable functionalities for components. As it is stated in the official Vue documentation, when a component uses a mixin, all options in the mixin will be “mixed” into the component’s own options.

For instance, routes and state management are a good fit for a plugin because in this case, a plugin enables you to affect changes without setting up props or listeners. However, this wouldn’t be the optimal choice for a functionality you intended for a specific component.

If you’re dealing with enterprise-level projects that have up to 500 or more files, mixins are not advisable. Here, hooks will run on each one’s life cycle, which is not quite cost effective. Also, there is always an option of exporting both the mixin and the plugin independently.

Great Vuex Plugins You Can Use

Vue developers have created lots of great and free plugins that you can instantly pick-up and apply to your project. However, like any other community that offers free solutions, dividing wheat from chaff requires some critical thinking and experimenting.

Since we at Share IT have been down with Vuex for a while, in this part of the article we have decided to share some of our personal favorite plugins.

Let’s dive right in:

1. Vuex-persistatedstate

This is a great tool that doesn’t do a lot, but its impact is absolutely huge in the ecommerce world. With vuex-persistatedstate, users can refresh browser pages and close tabs without whipping their data clean from them.

This is incredibly useful for people who run online stores. If, for instance, a user adds multiple items to the shopping cart while browsing a website, his/her activity won’t be immediately whipped out if he/she accidentally exits the site.

Nobody likes to go through multiple product pages again and try to remember everything they considered worth buying. In the ecommerce development, vuex-persistatedstate is an absolute must have.

2. Vuex-shared-mutations

This amazing plugin synchronizes states between different browser tabs by storing a mutation on a local state.

The storage then sets off an update across all the tabs and windows that are connected, which replays the mutations and thus, keeps the state in sync.

3. Vuex-i18

Perfect plugin for sites that come in multiple languages. Vuex-i18 lets you easily store content in many different languages.

Thanks to its ability to store strings with tokens, it makes it almost effortless to switch from one language to another within the app.

4. Vuex-loading

This sweet plugin enables multiple states to load in your application. This is a great solution for those who are building real-time apps where changes in state are frequent and complex.

5. Vuex-cache

This one is a bit self-explanatory. Vuex-cache is built to help you cache your Vuex actions, which is super useful if you're, for instance, fetching data from a server.

This plugin will help you capture your action the first time you do it manually, and will then return the cached value wherever you try to replicate the command. Of course, you can clear the cache with ease whenever you want to stop using it.

At Share IT, We’re Proud of Our Vue Developers

If you’re a developer who’s still learning about Vue and Vuex, we invite you to follow Share IT’s blog. Throughout time, our team has grown and we added new technologies and frameworks to the list, which is why we try our best to share the knowledge with the community on a regular basis.

Not only that, but one of our core business values is to dedicate extra time and effort to educate our clients and find the best solution for their specific project.

That being said, Vue can be a great framework choice and it has been used heavily in app development. In one of our previous posts, we mentioned great brands that used Vue for development such as Grammarly, 9GAG, Nintendo, WizzAir, Buzzfeed.

Based on your project requirements and capabilities, we’ll suggest the optimal tools, technologies, and processes to guide you through each step of the way. From analysis and specification to production and maintenance, we got you covered. Contact Share IT to discuss your project today.