Search code examples
nuxt.jsvuejs3server-side-renderingnuxt3.jspinia

Does Nuxtjs3 support NuxtServerInit


I used Pinia for creating a data in Nuxtjs 3. It works correctly, But I'd like to check that the data is rendered through the server not just client. How can I be sure about that? and Does nuxtServerInit is supported in new version of Nuxtjs 3?


Solution

  • You can try us this within creating plugin

    export default defineNuxtPlugin((nuxtApp) => {
      if (process.server) {
        // ...
      }
    })
    

    Found exact answer related to Pinia: https://github.com/vuejs/pinia/discussions/947#discussioncomment-1943854

    Main source: https://v3.nuxtjs.org/bridge/bridge-composition-api#definenuxtplugin

    EDIT: omit the import as Nuxt handle it