Skip to content
Sapphire UIv4.1.0

Seo Head

Set document metadata for titles, descriptions and link previews. Use it at the page boundary so metadata describes the current page rather than an embedded example.

Examples

Metadata

Generated document metadata, shown as text to preserve this page's title and description.

<title>Sapphire metadata example</title><meta name="description" content="Accessible document metadata"/><meta name="robots" content="index, follow"/><meta property="og:title" content="Sapphire metadata example"/><meta property="og:description" content="Accessible document metadata"/><meta property="og:type" content="website"/><meta property="og:site_name" content="KONGMY"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Sapphire metadata example"/><meta name="twitter:description" content="Accessible document metadata"/><script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","name":"KONGMY","url":"https://sapphire.kongmy.dev"}</script><p>Document metadata includes a title, description, and website structured data.</p>
JSX usage

Install this example’s dependencies, load the package stylesheet from Setup, and add Example CSS where shown. The snippet includes its local helpers.

bun add @kongmy-dev/sapphire-ui react react-dom
"use client";
import { SEOHead } from "@kongmy-dev/sapphire-ui/seo-head";

function MetadataExample() {
  return (
    <>
      <SEOHead
        title="Sapphire metadata example"
        description="Accessible document metadata"
        isWebSite
      />
      <p>
        Document metadata includes a title, description, and website structured
        data.
      </p>
    </>
  );
}

export default MetadataExample;
HTML markup

Initial rendered HTML only. React handlers and portalled content require the JSX example; static HTML does not reproduce those interactions.

Raw Html

JSX usage

Install this example’s dependencies, load the package stylesheet from Setup, and add Example CSS where shown. The snippet includes its local helpers.

bun add @kongmy-dev/sapphire-ui react react-dom
"use client";
import { generateSEOTags } from "@kongmy-dev/sapphire-ui/seo-head";

function RawHTMLExample() {
  return (
    <pre>
      {generateSEOTags({
        title: 'Server-rendered metadata',
        description: 'Works without React.',
      })}
    </pre>
  );
}

export default RawHTMLExample;
HTML markup

Initial rendered HTML only. React handlers and portalled content require the JSX example; static HTML does not reproduce those interactions.

Props

Generated from the current public TypeScript signatures, including composed behaviour props. “—” means no default is declared in the local signature; forwarded behaviour defaults are not inferred.

SEOHead

SEOHead component props
PropTypeRequiredLocal default
titlestringYes—
descriptionstringYes—
urlstringNo—
imagestringNo—
siteNamestringNo—
type"article" | "website"No—
localestringNo—
hreflangRecord<string, string>No—
preconnectstring[]No—
preload{ href: string; as: string; type?: string; crossOrigin?: "" | "anonymous" | "use-credentials"; }[]No—
isWebSitebooleanNo—
isOrganizationbooleanNo—
omitDefaultOrganizationDetailsbooleanNo—
twitterCard"summary" | "summary_large_image"No—
twitterSitestringNo—
publishedTimestringNo—
authorstringNo—
keywordsstring[]No—
robotsstringNo—
jsonLdRecord<string, unknown>No—
childrenReactNodeNo—

Setup

bun add @kongmy-dev/sapphire-ui react react-dom

For an app using package components throughout, load the full stylesheet once. Add this component import where you use it.

import "@kongmy-dev/sapphire-ui/sapphire.css";
import { SEOHead } from "@kongmy-dev/sapphire-ui/seo-head";

Mixing package and vendored components? Follow application setup.

Search documentation