diff --git a/packages/nuxt3/src/app/_templates/plugins.ts b/packages/nuxt3/src/app/_templates/plugins.ts index 0485fd9f1d..50c8dc6355 100644 --- a/packages/nuxt3/src/app/_templates/plugins.ts +++ b/packages/nuxt3/src/app/_templates/plugins.ts @@ -1,8 +1,10 @@ +import head from 'nuxt/app/plugins/head' import router from 'nuxt/app/plugins/router' import vuex from 'nuxt/app/plugins/vuex' import legacy from 'nuxt/app/plugins/legacy' export default [ + head, router, vuex, legacy diff --git a/packages/nuxt3/src/app/plugins/head.ts b/packages/nuxt3/src/app/plugins/head.ts new file mode 100644 index 0000000000..3f296b23e8 --- /dev/null +++ b/packages/nuxt3/src/app/plugins/head.ts @@ -0,0 +1,13 @@ +import type { Plugin } from 'nuxt/app' +import { createHead, renderHeadToString } from '@vueuse/head' + +export default function head (nuxt) { + const { app, ssrContext } = nuxt + const head = createHead() + + app.use(head) + + if (process.server) { + ssrContext.head = () => renderHeadToString(head) + } +}