Overview
The nuxtClientInit module is a module for Nuxt.js that provides the ability to inject processing at client initialization. It is similar to the nuxtServerInit module but is executed only on the client-side rendering, in the root Vuex module.
Features
- Client-Side Initialization: Allows developers to implement the nuxtClientInit action, which is executed only on the client-side rendering, in the root Vuex module.
- Easy Installation: Can be easily installed and used in Nuxt.js projects.
- Compatible with Other Modules: Works seamlessly with other modules, such as axios, that may be needed during the nuxtClientInit process.
Installation
- Add the nuxtClientInit module to your Nuxt.js project by running the following command:
npm install nuxt-client-init-module
- In your
nuxt.config.js
file, add the module to themodules
section:
{
modules: [
'nuxt-client-init-module'
// other modules
]
}
- In your Vuex store’s
index.js
file, you can now implement the nuxtClientInit action:
export const actions = {
nuxtClientInit({ commit }) {
// your initialization logic here
}
}
Note: Make sure that the nuxt-client-init-module
appears earlier in the modules section of your nuxt.config.js
file if you need to use other modules during the nuxtClientInit process.
Summary
The nuxtClientInit module provides Nuxt.js users with the ability to execute actions only on the client-side rendering. It can be easily installed and used in Nuxt.js projects, and works well with other modules that may be required during the client-side initialization process.