Structured Data

Type-safe JSON-LD helpers and the StructuredData component for website, article, and breadcrumb graphs.

Structured Data APILink

Boltdocs emits JSON-LD for search engines and crawlers through seo.structuredData or the <StructuredData /> client component. It is separate from the internal search index.

The convenient factoryLink

Use createStructuredData() when a page needs one or more common graph nodes. Structured Data is a stable SEO API; only View Transitions and experimental.fileRouting require opt-in:

ts
import { createStructuredData, defineConfig, defineStructuredData } from 'boltdocs'

export default defineConfig({
  seo: {
    structuredData: defineStructuredData(
      createStructuredData({
        website: {
          name: 'Example Docs',
          url: 'https://example.com',
        },
        article: {
          headline: 'Getting Started',
          url: 'https://example.com/docs/start',
          description: 'Install and configure the project.',
          datePublished: '2026-08-01',
          author: 'Example Team',
        },
        breadcrumbs: [
          { name: 'Docs', url: 'https://example.com/docs' },
          { name: 'Getting Started', url: 'https://example.com/docs/start' },
        ],
      }),
    ),
  },
})

The factory returns one object when exactly one preset is provided and an array when multiple nodes are provided. It throws a clear error when no graph input is provided. Use additional for schema types that do not have a built-in preset:

ts
const data = createStructuredData({
  additional: {
    '@context': 'https://schema.org',
    '@type': 'SoftwareApplication',
    name: 'Example App',
    applicationCategory: 'DeveloperApplication',
  },
})

Preset optionsLink

websiteLink

PropertyTypeRequiredDescription
namestringyesPublic website name.
urlstringyesCanonical website URL.
descriptionstringnoWebsite description.
searchUrlstringnoSearch endpoint containing the query prefix, such as https://example.com/search?q=.

articleLink

PropertyTypeRequiredDescription
headlinestringyesArticle or page headline.
urlstringyesCanonical page URL.
descriptionstringnoArticle summary.
datePublishedstring | DatenoPublication date, normalized to ISO.
dateModifiedstring | DatenoLast modification date, normalized to ISO.
imagestringnoAbsolute or resolved image URL.
authorstring | { name, url? }noPerson name or person object.

Pass an ordered array of { name, url } objects. Positions are generated automatically starting at 1.

ts
const breadcrumbs = createStructuredData({
  breadcrumbs: [
    { name: 'Docs', url: 'https://example.com/docs' },
    { name: 'API', url: 'https://example.com/docs/api' },
  ],
})

Page-level MDX dataLink

Add a graph directly to a page's frontmatter:

mdx

Global seo.structuredData and page-level data are emitted together.

External React pagesLink

Render JSON-LD from a page under pages-external/:

tsx
import { StructuredData, createStructuredData } from 'boltdocs/client'

export default function AboutPage() {
  const data = createStructuredData({
    article: {
      headline: 'About Example',
      url: 'https://example.com/about',
    },
  })

  return (
    <>
      <StructuredData data={data} id="about-jsonld" />
      <main>About Example</main>
    </>
  )
}

The component safely escapes < before writing the application/ld+json script.

Existing specialized helpersLink

These helpers remain supported when you prefer explicit construction:

ts
import {
  createArticleStructuredData,
  createBreadcrumbStructuredData,
  createWebSiteStructuredData,
  defineStructuredData,
} from 'boltdocs'

defineStructuredData() preserves literal TypeScript types; it does not modify the runtime value.

Last updated on October 18, 2026

Was this page helpful?