Skip to content
Discussion options

You must be logged in to vote

I spent hours on all the docs, including nitro, pinia, looking for hooks, reading source code, so I hope this answer can help someone.

When people talk about server plugin they usually talk about a regular plugin suffixed by .server and exposed with defineNuxtPlugin. They usualy don't talk about /server/plugins.

In order to have a nuxtServerInit action, use this file:

// /plugins/nuxtServerInit.server.ts file
import { useGeneralStore } from '~~/stores/general'

export default defineNuxtPlugin(async () => {
  const generalStore = useGeneralStore()
  await generalStore.fetchSomething()
})
// /stores/general.ts file
import { defineStore } from 'pinia'

interface State {
  aaa: string
}

export 

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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