I have a vue app built in Nuxt which has vue routing / history enabled.
The problem is when I save something to the app state / Vuex, it changes on the single page fine but when I navigate to a new page it's been cleared and returns the state to it's default values.
Do I have to do something to enable the state management in vuex to work on different pages?
store/index.js
import Vuex from "vuex"
const createStore = () => {
return new Vuex.Store({
state: {
count: 10,
username: "John Smith",
loggedIn: false
},
mutations: {
loginStatus(state, status) {
state.loggedIn = status
},
setUsername(state, name) {
state.username = name
}
}
})
}
export default createStore
Code from the vue app
this.$store.commit("loginStatus", true)
this.$store.commit("setUsername", "Adam")