Skip to content

Guide · Open source

How to use Vuex: store, state and devtools basics

Updated · written with AI from the project's own documentation and checked against our catalogue data

Vuex is a state management library for Vue.js applications. It keeps shared application data in one central store that every component can read, and it enforces rules so changes to that data happen predictably. This guide explains what Vuex does, how to run its bundled examples, and when the project's own README recommends a different library.

Vuexvuejs/vuex · ★ 28.3k · MIT

Quick start

  1. 1Decide between Vuex and Pinia. If you are starting a new Vue project, the README recommends Pinia. Keep Vuex if you maintain an existing Vuex app.
  2. 2Read the official docs. Visit vuex.vuejs.org for the full documentation and the 'What is Vuex?' overview.
  3. 3Make sure Node.js and npm are installed. The README lists Node.js and npm as the prerequisites for running the examples.
  4. 4Clone the repository. Get the vuejs/vuex source so you can open the examples directory.
  5. 5Install dependencies. Run npm install in the repository root to install what the examples need.
  6. 6Serve the examples. Run npm run dev and open localhost:8080 to view the example applications.

Understand what Vuex is for

Vuex is described as a state management pattern and library for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.

It also integrates with Vue's official devtools extension, which provides features such as zero-config time-travel debugging and state snapshot export and import.

  • One central store shared by all components
  • Rules that keep state changes predictable
  • Devtools integration for time-travel debugging and snapshot export/import

Check whether Pinia is the better choice first

The README states that Pinia is now the official default state management library for Vue. Vuex 3 and 4 will still be maintained, but it is unlikely new functionality will be added to them.

The README says that if you are starting a new project, it highly recommends using Pinia instead. If you are migrating an existing Vuex app, it notes Pinia might be a suitable option, and that Vuex and Pinia can be installed in the same project.

  • Existing Vuex app: keep using Vuex, or migrate gradually to Pinia
  • New Vue project: the README recommends Pinia

Run the bundled Vuex examples

Vuex keeps example applications under the examples directory. The README lists the prerequisites for running them as Node.js and npm.

From the repository root, install dependencies and then serve the examples locally. The README says the dev server runs at localhost:8080.

  • Prerequisites: Node.js and npm
  • Examples live in the examples directory
$ npm install $ npm run dev # serve examples at localhost:8080

Find the documentation and get help

The full documentation is at vuex.vuejs.org. For questions and support, the README points to the Discord chat server and the official Vue forum.

The GitHub issue list is reserved for bug reports and feature requests. Read the Issue Reporting Checklist before opening an issue, since issues that do not follow the guidelines may be closed.

  • Docs: vuex.vuejs.org
  • Questions: Discord chat server or the official forum
  • Issues: bug reports and feature requests only

What people use it for

  • Maintaining an existing Vue application that already uses a centralized Vuex store
  • Migrating a Vuex codebase gradually toward Pinia
  • Debugging shared state with devtools time-travel and snapshot export/import
  • Studying example applications in the examples directory

Frequently asked questions

Is Vuex free to use?

Yes. Vuex is released under the MIT licence, and its copyright notice reads Copyright (c) 2015-present Evan You.

Is Vuex still maintained?

The README says Vuex 3 and 4 will still be maintained, but it is unlikely to add new functionalities to them. The official recommendation for Vue state management is now Pinia.

Should I use Vuex or Pinia for a new project?

Use Pinia. The README says that if you are planning to start a new project, it highly recommends using Pinia instead.

What are the requirements to run the Vuex examples?

The README lists Node.js and npm as the prerequisites. Run npm install and then npm run dev to serve the examples at localhost:8080.

Where do I get help if something does not work?

For questions and support, use the Discord chat server at chat.vuejs.org or the official forum at forum.vuejs.org. The GitHub issues are only for bug reports and feature requests.

What are alternatives to Vuex?

The project lists Pinia, Redux, Zustand and MobX as comparable projects. For Vue specifically, the README points to Pinia as the default.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Vuex suits teams maintaining an existing Vue app that already uses it, or migrating gradually to Pinia, especially when devtools time-travel debugging matters. For new Vue projects, the README recommends Pinia, and developers who want new state management features should look there instead.

Install options & downloads