From the course: Building Vue and Node Apps with Authentication

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Intro to Vuex

Intro to Vuex

From the course: Building Vue and Node Apps with Authentication

Start my 1-month free trial

Intro to Vuex

- [Instructor] In this video, we'll get a quick introduction to Vuex, which will replace our existing data store that we created in the last video. Let's head over to the front-end project and let's open up a new terminal. We'll need to install Vuex, so we'll use npm install vuex --save. After installing Vuex, let's go over to our store.js from vuex. And in order to tell Vue that we'd like to use Vuex, we need to call Vue.use and pass in Vuex. But in order to access Vue, we'll need to import that also. So above our first import call, we'll add another import, Vue from vue. And I'll close the terminal just to get some more screen space. Next, I'll wrap the object we're exporting with new Vuex.Store and I'll pass in the object to that function. Now, let's save that and open up our Messages component. And since we're using Vuex, we no longer need to import store.js, so I'll delete line 19. I'll also remove our declaration on line 23. And we can now access the store through this. So on…

Contents