Skip to content

help: plugin breaks devToolsย #907

@MartyNZ

Description

@MartyNZ

๐Ÿ“š What are you trying to do?

I have a project I'm upgrading from Nuxt v3 to v4. My app requires plugins that make the call to the CMS for intiial settings and Data etc. When I add my plugin

/* get global page data on start */
export default defineNuxtPlugin(async (nuxtApp) => {
  const siteSettingsStore = useSiteSettingsStore();
  await siteSettingsStore.fetchStoreSettings();

  const siteNavigation = useSiteNavigationStore();
  await siteNavigation.fetchStoreNavigation();

  // Add all the stores to the Nuxt context
  nuxtApp.provide("siteSettingsStore", siteSettingsStore);
  nuxtApp.provide("siteNavigation", siteNavigation);
});

to the app devTools is no longer available...

๐Ÿ” What have you tried?

Any change I make to the plugin code, namely adding app:created hook, or removing the async/await results the following error
"A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function."

โ„น๏ธ Additional context

I also get the following error in the browser console.
"The resource http://localhost:3000/_nuxt/builds/meta/dev.json was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally."

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions