What is the nuxtServerInit method for? Where should I add it?

nuxtServerInit ({ commit }, { req }) {
  if (req.session && req.session.authUser) {
    commit("SET_USER", req.session.authUser)
  }
}

where should this method be added to store/index.js?

Jul.08,2021

used for to operate store on the server is essentially an Action, written in actions . Its payload is the context object of Nuxt App.

Resources:

  1. ide/vuex-store-sharpthe-nuxtserverinit-action" rel=" nofollow noreferrer "> The nuxtServerInit Action
Menu