Skip to content

nuxtServerInit working on dev but not on start - alternatives? #901

Answered by Jesus82
Jesus82 asked this question in Q&A
Discussion options

You must be logged in to vote

Solution was to rename the file to

plugins/01.init.server.ts

and add it to the plugins object in nuxt.config.ts (very important, if not it doesn't work)

plugins: [{ src: '~/plugins/01.init.server' }],

Then no need for a hook as it executes on server side

export default defineNuxtPlugin(nuxtApp => {
    nuxtApp.nuxt2Context.store.dispatch('myVuexAction')
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jesus82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant