Hey, very nice article, I am currently trying to use strapi in nuxt3 however $strapi is no longer injected globally for me. I only get Unresolved variable $strapi / Cannot read properties of undefined (reading '$strapi') error messages. Do you have any idea what the problem could be?
Hi Jannik, I am glad you liked the article!
I think that the current approach for accessing integration variables (like we used this.$strapi in Nuxt 2) is now transitioned into using nuxt app composable or runtime config composable (useNuxtApp/useRuntimeConfig). Can you try to use any of these composables in your setup function? Something like this
useRuntimeConfig should do the thing due to this line -> github.com/nuxt-community/strapi-m... but useNuxtApp can be useful for some older Nuxt modules that used to override the context. Let me know if that fixed the issue for you.
Have yet found something hidden in the docu regarding nuxt3 and strapi 4. $strapi was replaced by the auto imported useStrapi4. But thanks for your answer that I can use very well for older nuxt libraries :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey, very nice article, I am currently trying to use strapi in nuxt3 however $strapi is no longer injected globally for me. I only get Unresolved variable $strapi / Cannot read properties of undefined (reading '$strapi') error messages. Do you have any idea what the problem could be?
Hi Jannik, I am glad you liked the article!
I think that the current approach for accessing integration variables (like we used this.$strapi in Nuxt 2) is now transitioned into using nuxt app composable or runtime config composable (useNuxtApp/useRuntimeConfig). Can you try to use any of these composables in your setup function? Something like this
useRuntimeConfig should do the thing due to this line -> github.com/nuxt-community/strapi-m... but useNuxtApp can be useful for some older Nuxt modules that used to override the context. Let me know if that fixed the issue for you.
Have yet found something hidden in the docu regarding nuxt3 and strapi 4. $strapi was replaced by the auto imported useStrapi4. But thanks for your answer that I can use very well for older nuxt libraries :)