diff --git a/docs/3.api/4.advanced/1.hooks.md b/docs/3.api/4.advanced/1.hooks.md index 2a727cb6eb..af93555a06 100644 --- a/docs/3.api/4.advanced/1.hooks.md +++ b/docs/3.api/4.advanced/1.hooks.md @@ -38,6 +38,7 @@ Hook | Arguments | Description `kit:compatibility` | `compatibility, issues` | Allows extending compatibility checks. `ready` | `nuxt` | Called after Nuxt initialization, when the Nuxt instance is ready to work. `close` | `nuxt` | Called when Nuxt instance is gracefully closing. +`restart` | - | Called to restart the current Nuxt instance. **This hook is currently only available on the [Edge Channel](/docs/guide/going-further/edge-channel/).** `modules:before` | - | Called during Nuxt initialization, before installing user modules. `modules:done` | - | Called during Nuxt initialization, after installing user modules. `app:resolve` | `app` | Called after resolving the `app` instance. diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index 1c725b0dc8..139d69e629 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -89,6 +89,8 @@ export default defineNuxtCommand({ } currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false }) + currentNuxt.hooks.hookOnce('restart', () => load(true)) + if (!isRestart) { showURL() } diff --git a/packages/schema/src/types/hooks.ts b/packages/schema/src/types/hooks.ts index 6b882387c2..566b89042b 100644 --- a/packages/schema/src/types/hooks.ts +++ b/packages/schema/src/types/hooks.ts @@ -61,7 +61,7 @@ export interface NuxtHooks { 'kit:compatibility': (compatibility: NuxtCompatibility, issues: NuxtCompatibilityIssues) => HookResult // Nuxt - /** + /** * Called after Nuxt initialization, when the Nuxt instance is ready to work. * @param nuxt The configured Nuxt object * @returns Promise @@ -73,6 +73,11 @@ export interface NuxtHooks { * @returns Promise */ 'close': (nuxt: Nuxt) => HookResult + /** + * Called to restart the current Nuxt instance. + * @returns Promise + */ + 'restart': () => HookResult /** * Called during Nuxt initialization, before installing user modules.