smolter
API

Meta

Render metadata selected from the active route or root module.

Compatibility

ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/preact/document @kasperrt/smolter/react/document

Signature

function Meta(): import("preact").JSX.Element;

Parameters

Takes no props and requires application context. Place it in the root Layout head.

Returns

Renders title, meta, link, and JSON-LD elements from metadata descriptors. The active route’s meta function receives the current loader data, params, error, and URL. If it is absent, the root meta function is used.

Example

Define metadata in a separate meta.ts file, re-export it from the route module, and render Meta in the shared document layout.

import { Meta } from "@kasperrt/smolter/preact/document";

export function DocumentHead() {
  return (
    <head>
      <meta charSet="utf-8" />
      <Meta />
    </head>
  );
}

Selection and updates

Route and root descriptors are not merged: an active route returning [] suppresses root fallback metadata. The browser title is synchronized when a title descriptor is present. JSON-LD is serialized with serializeData so embedded less-than characters cannot close the script element.

View implementation ↗