preactjs / preactjs/preact

Support for Document Metadata in Preact

Open
#4,695 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

compat feature request
Dominant language
JavaScript
Stars
38.9k
Forks
2.4k
Avg merge
20h 18m
Merged PRs (30d)
35

Description

With the release of React 19’s support for document metadata, managing <title>, <meta>, and other head elements has become convenient, it eliminated the need to use packages like react-helmet to manage these tags. However, when attempting to use preact/compact in my vite.config.ts to render my components, I encountered an issue:

While most functionality worked as expected, metadata tags defined within my pages were not handled correctly. Instead of being embedded in the document <head>, they were rendered inside the body section of my components. This behavior is undesirable and could impact proper SEO and metadata management.

I wanted to check if Preact plans to introduce support for document metadata, similar to React 19. This would be a valuable addition that would make it easier for developers to manage metadata seamlessly when leveraging Preact’s performance benefits.

Would love to hear your thoughts on this!
Thanks for all your great work.

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 by reproducing the behavior with preact/compact configured in vite.config.ts, then compare it with React 19's document metadata behavior. The work would be complete when title, meta, and other supported head elements are placed in the document head rather than the component body, with coverage for the supported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.