diff --git a/docs/2.guide/2.directory-structure/1.plugins.md b/docs/2.guide/2.directory-structure/1.plugins.md index 4a29e5bbc8..6851731978 100644 --- a/docs/2.guide/2.directory-structure/1.plugins.md +++ b/docs/2.guide/2.directory-structure/1.plugins.md @@ -157,6 +157,7 @@ Normally, Vue.js composables are bound to the current component instance while p If you would like to provide a helper on the [`NuxtApp`](/docs/api/composables/use-nuxt-app) instance, return it from the plugin under a `provide` key. +::code-group ```ts [plugins/hello.ts] export default defineNuxtPlugin(() => { return { @@ -166,6 +167,19 @@ export default defineNuxtPlugin(() => { } }) ``` +```ts [plugins/hello-object-syntax.ts] +export default defineNuxtPlugin({ + name: 'hello', + setup () { + return { + provide: { + hello: (msg: string) => `Hello ${msg}!` + } + } + } +}) +``` +:: You can then use the helper in your components: