docs: document parallel option on plugins (#21622)

This commit is contained in:
Julien Huang 2023-06-18 18:43:39 +02:00 committed by GitHub
parent a0c2363616
commit 794449f469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,20 @@ This is useful in situations where you have a plugin that depends on another plu
In case you're new to 'alphabetical' numbering, remember that filenames are sorted as strings, not as numeric values. For example, `10.myPlugin.ts` would come before `2.myOtherPlugin.ts`. This is why the example prefixes single digit numbers with `0`.
::
## Loading strategy
By default, Nuxt loads plugins sequentially. You can define a plugin as `parallel` so Nuxt won't wait the end of the plugin's execution before loading the next plugin.
```ts
export default defineNuxtPlugin({
name: 'my-plugin',
parallel: true,
async setup (nuxtApp) {
// the next plugin will be executed immediatly
}
})
```
## Using Composables Within Plugins
You can use [composables](/docs/guide/directory-structure/composables) within Nuxt plugins: