Skip to content

Conversation

@everton-dgn
Copy link
Contributor

  • I have read the Contribution guide
  • This PR references an issue (except for typos, broken links, or other minor problems)

Description

Adds a useHead reference page for @solidjs/meta covering signature, parameters, SSR/hydration behavior, escaping, and examples (including JSON-LD).

The new page is available at /solid-meta/reference/meta/use-head.

Wires the page into the solid-meta reference navigation and links it from the setup guide.

Related issues & labels

  • Closes #N/A
  • Suggested label(s) (optional): documentation

How to test locally:

pnpm sync
pnpm check:types
pnpm check:lint

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Dec 26, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 80437b8
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/6951a383c2797b0008d121bc
😎 Deploy Preview https://deploy-preview-1387--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@LadyBluenotes LadyBluenotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting in the work for this! I have some changes to keep it consistent with the other pages :)

Comment on lines 25 to 43

## When to use useHead

- Insert tags without built-in components, such as `script` and `noscript`.
- Control SSR output with `setting.close` and `setting.escape`.
- Inject per-page structured data like JSON-LD.
- Reuse an existing element via `ref`.

## Prefer components when possible

Use the dedicated components when they fit your use case:

- [`<Title />`](/solid-meta/reference/meta/title) for page titles.
- [`<Meta />`](/solid-meta/reference/meta/meta) for metadata.
- [`<Link />`](/solid-meta/reference/meta/link) for external resources.
- [`<Style />`](/solid-meta/reference/meta/style) for inline styles.
- [`<Base />`](/solid-meta/reference/meta/base) for base URLs.

They provide clearer intent and sensible defaults.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally try to avoid explanations in the reference section, since its goal is to document the API surface as clearly and directly as possible. We generally try to avoid explanations in the reference section, since its goal is to document the API surface as clearly and directly as possible. Keeping references concise makes them easier to scan and helps readers quickly understand what exists and how it’s shaped, without additional narrative getting in the way.

With that in mind, do you mind removing these sections?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Sure, I can remove those sections.

Comment on lines 204 to 238
## Notes

### SSR and hydration

On the server, tags are collected and rendered into `<head>`.
During hydration, tags with matching `id` values are reused.
On client-only renders, existing server tags are removed and replaced.

### Dedupe and idempotency

For `title` and `meta`, only the most recent tag with the same key is kept.
The key is derived from the tag name and selected attributes.
For `meta`, the key uses `name` (or `property`), `http-equiv`, `content`, `charset`, and `media`.
For `title`, the key does not include any attributes.
Other tag types are not deduped.
The `id` does not control deduping.
It ensures hydration can reuse the same element instead of inserting a duplicate.

### Reactive updates and cleanup

`useHead` runs inside a render effect.
If your tag description reads reactive values, the tag updates when those values change.
When the component unmounts, the tag is removed and any previous cascading tag is restored.

### Security and escaping

Use `setting.escape: true` when inserting untrusted content.
Setting `escape: false` renders raw HTML and can create XSS risks.
Only use `escape: false` with trusted, pre-serialized strings such as JSON-LD.

### Best practices

Use stable, unique `id` values to avoid duplicates.
Prefer the dedicated head components when they meet your needs.
Avoid inserting multiple tags that represent the same metadata unless you intend to override.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the comment above, we want to avoid adding any of these explanation points to the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your help and the detailed feedback on the PR, it was extremely helpful. I believe I’ve incorporated all the feedback into the code. When you have a chance, could you please review the latest changes?

everton-dgn and others added 10 commits December 28, 2025 17:25
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Co-authored-by: Sarah <hello@sarahgerrard.me>
Copy link
Member

@LadyBluenotes LadyBluenotes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work, thank you!

@LadyBluenotes LadyBluenotes enabled auto-merge (squash) December 28, 2025 21:35
@LadyBluenotes LadyBluenotes merged commit c9801a1 into solidjs:main Dec 28, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants