From 110f1d0b2f8b9f5856461198666f515bf435de43 Mon Sep 17 00:00:00 2001 From: Idorenyin Udoh Date: Thu, 20 Feb 2025 17:13:25 +0100 Subject: [PATCH] docs: mention requirement to wrap middleware in `defineNuxtRouteMiddleware` (#31005) --- docs/2.guide/3.going-further/6.nuxt-app.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/2.guide/3.going-further/6.nuxt-app.md b/docs/2.guide/3.going-further/6.nuxt-app.md index 907e68553e..af5c82a860 100644 --- a/docs/2.guide/3.going-further/6.nuxt-app.md +++ b/docs/2.guide/3.going-further/6.nuxt-app.md @@ -23,7 +23,7 @@ Jump over the `NuxtApp` interface documentation. Many composables and utilities, both built-in and user-made, may require access to the Nuxt instance. This doesn't exist everywhere on your application, because a fresh instance is created on every request. -Currently, the Nuxt context is only accessible in [plugins](/docs/guide/directory-structure/plugins), [Nuxt hooks](/docs/guide/going-further/hooks), [Nuxt middleware](/docs/guide/directory-structure/middleware), and [setup functions](https://vuejs.org/api/composition-api-setup.html) (in pages and components). +Currently, the Nuxt context is only accessible in [plugins](/docs/guide/directory-structure/plugins), [Nuxt hooks](/docs/guide/going-further/hooks), [Nuxt middleware](/docs/guide/directory-structure/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup.html) (in pages and components). If a composable is called without access to the context, you may get an error stating that 'A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.' In that case, you can also explicitly call functions within this context by using [`nuxtApp.runWithContext`](/docs/api/composables/use-nuxt-app#runwithcontext).