store | nuxt store action
The store directorycontainsyour VuexStore files.TheVuexStorecomeswithNuxtoutoftheboxbutisdisabledbydefault.Creatinganindex.js fileinthisdirectoryenablesthestore.Thisdirectorycannotberenamedwithoutextraconfiguration.Usingastoretomanagethestateisimportantforeverybigapplication.ThatswhyNuxtimplements Vuex initscore.Nuxtwilllookforthestoredirectory.Ifitcontainsafile,thatisntahiddenfileoraREADME.mdfile,thenthestorewillbeactivated.ThismeansthatNuxtwill:ImportVuex,AddthestoreoptiontotherootVueinsta...
The store directory contains your Vuex Store files. The Vuex Store comes with Nuxt out of the box but is disabled by default. Creating an index.js file in this directory enables the store.
This directory cannot be renamed without extra configuration.
Using a store to manage the state is important for every big application. Thats why Nuxt implements Vuex in its core.
Nuxt will look for the store directory. If it contains a file, that isnt a hidden file or a README.md file, then the store will be activated. This means that Nuxt will:
Import Vuex, Add the store option to the root Vue instance.Every .js file inside the store directory is transformed as a namespaced module [1] (index being the root module). Your state value should always be a function to avoid unwanted shared state on the server side.
To get started, exp...