diff --git a/packages/app/src/_templates/entry.client.js b/packages/app/src/_templates/entry.client.js index d862fe3a06..28d7ae2e49 100644 --- a/packages/app/src/_templates/entry.client.js +++ b/packages/app/src/_templates/entry.client.js @@ -13,12 +13,12 @@ async function initApp () { await applyPlugins(nuxt, plugins) await applyPlugins(nuxt, clientPlugins) - await app.$nuxt.hooks.callHook('app:created', app) - await app.$nuxt.hooks.callHook('app:beforeMount', app) + await nuxt.hooks.callHook('app:created', app) + await nuxt.hooks.callHook('app:beforeMount', app) app.mount('#__nuxt') - await app.$nuxt.hooks.callHook('app:mounted', app) + await nuxt.hooks.callHook('app:mounted', app) await nextTick() nuxt.isHydrating = false } diff --git a/packages/app/src/_templates/entry.server.js b/packages/app/src/_templates/entry.server.js index 1cfda1d1b4..ff127972f8 100644 --- a/packages/app/src/_templates/entry.server.js +++ b/packages/app/src/_templates/entry.server.js @@ -12,11 +12,7 @@ export default async function createNuxtAppServer (ssrContext = {}) { await applyPlugins(nuxt, plugins) await applyPlugins(nuxt, serverPlugins) - await app.$nuxt.hooks.callHook('app:created', app) - - nuxt.hooks.hook('vue-renderer:done', - () => nuxt.hooks.callHook('app:rendered', app) - ) + await nuxt.hooks.callHook('app:created', app) return app } diff --git a/packages/nitro/src/runtime/app/render.ts b/packages/nitro/src/runtime/app/render.ts index 32fb82d047..d764f4f8e2 100644 --- a/packages/nitro/src/runtime/app/render.ts +++ b/packages/nitro/src/runtime/app/render.ts @@ -41,6 +41,11 @@ export async function renderMiddleware (req, res) { ...(req.context || {}) } const rendered = await renderer.renderToString(ssrContext) + + if (ssrContext.nuxt.hooks) { + await ssrContext.nuxt.hooks.callHook('app:rendered') + } + // TODO: nuxt3 should not reuse `nuxt` property for different purpose! const payload = ssrContext.payload /* nuxt 3 */ || ssrContext.nuxt /* nuxt 2 */