nuxt / nuxt/bridge

useMeta doesn't seem to render server-side

Open
#51 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
285
Forks
33
Avg merge
22h 38m
Merged PRs (30d)
3

Description

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: yarn@1.22.17
  • Bundler: Webpack
  • User Config: head, components, modules, css, plugins, bridge, buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/bridge@3.0.0-27366343.1d741cb

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and compare its page source with the linked fixed reproduction. Trace how the useMeta composable is connected to Nuxt Bridge's server-side head rendering, using related PR 2419 and the linked issues for context. Done means the title and style metadata appear in the server-rendered head.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.