Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMeta doesn't seem to render server-side #51

Open
tylerforesthauser opened this issue Jan 14, 2022 · 2 comments
Open

useMeta doesn't seem to render server-side #51

tylerforesthauser opened this issue Jan 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@tylerforesthauser
Copy link

Environment

Nuxt CLI v3.0.0-27366343.1d741cb
RootDir: /sandbox
Nuxt project info:


  • Operating System: Linux
  • Node Version: v14.18.1
  • Nuxt Version: 2.16.0-27358576.777a4b7f
  • Package Manager: [email protected]
  • Bundler: Webpack
  • User Config: head, components, modules, css, plugins, bridge, buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Reproduction

https://codesandbox.io/s/nuxt-2-bridge-usemeta-render-issue-4ibyf

Describe the bug

When using Nuxt 2 with Nuxt Bridge and with the useMeta composable enabled, the metadata added via useMeta doesn't seem to be added server-side. This can be observed using the linked reproduction repo (separate window) and then viewing the page source. You'll see that the added title and style tags are not present in the head. Obviously this is not good for SEO, amongst other things.

Referring to a now closed PR that seemed to address this issue, I was able to craft a fix — https://codesandbox.io/s/fix-nuxt-2-bridge-usemeta-render-issue-txxnp (separate window). Loading that page and then viewing the source reveals the added meta info in the head, as expected.

I'm not knowledgeable enough to propose the above "fix" as a globally appropriate solution but I'm sure it could lead someone down the path to some kind of remedy for this behaviour.

Additional context

Potentially relevant related issues:

Potentially relevant related PR:

Logs

No response

@Destaq
Copy link

Destaq commented Jan 15, 2022

This issue also occurs with Nuxt 3 projects; if you create a pages directory, useMeta is first applied, then removed, and then reapplied.

When having a Nuxt 3 app with no pages/ folder, just app.vue, useMeta is applied before page render.

With the exact same configuration, but the addition of pages, any htmlAttrs in useMeta are applied after page render - a big problem as I'm using it to control the theme of my web app.

You can find a sample configuration here: saadeghi/daisyui#249 (comment)

The issue only happens when ssr is set to true.

@danielroe danielroe added bug Something isn't working and removed pending triage labels Jan 17, 2022
@toniengelhardt
Copy link

toniengelhardt commented Feb 2, 2022

Same issue with Nuxt 3, meta title, -description, etc. defined with useMeta() are rendered by the dev server but stripped out in production with SSR.

@danielroe danielroe transferred this issue from nuxt/framework Apr 13, 2022
@danielroe danielroe removed the bridge label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants