Nuxt Client Init Module screenshot

Nuxt Client Init Module

Author Avatar Theme by Potato4d
Updated: 12 Jan 2024
237 Stars

Provide client version of nuxtServerInit

Categories

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

  1. Add the nuxtClientInit module to your Nuxt.js project by running the following command:
npm install nuxt-client-init-module
  1. In your nuxt.config.js file, add the module to the modules section:
{
  modules: [
    'nuxt-client-init-module'
    // other modules
  ]
}
  1. 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.