# JsonLd

Escape-safe JSON-LD script renderer for schema.org structured data

> Component ID: `json-ld`
> Import: `import { JsonLd } from '@slipstream-ui/core'`
> Docs: https://slipstreamui.com/docs/components/json-ld
> Registry: https://slipstreamui.com/registry/json-ld.json
> Tier: atom · Package: @slipstream-ui/core@0.16.0
> Manifest schema: v1 · manifest: v1

## Design intent

JsonLd renders schema.org objects built by the seo utils (organizationJsonLd, articleJsonLd, faqJsonLd, ...) as a <script type="application/ld+json"> block. It escapes `<` inside string values so untrusted data can never close the script tag early — the failure mode plain JSON.stringify leaves open.

## Props

| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
| data | `JsonLdObject | JsonLdObject[]` | — | yes | Schema.org object or array of objects, typically built by the utils/seo builders |

## Examples

### FAQ structured data

FAQPage schema for visible Q&A content

```tsx
import { JsonLd, faqJsonLd } from '@slipstream-ui/core';

const site = { name: 'Acme', url: 'https://acme.dev' };

<JsonLd
  data={faqJsonLd({
    site,
    items: [
      { question: 'Is it free?', answer: 'Yes, MIT licensed.' },
    ],
  })}
/>
```

### Multiple entities

An array emits one script tag containing a JSON array

```tsx
<JsonLd
  data={[organizationJsonLd(site), webSiteJsonLd(site)]}
/>
```

## Anti-patterns

- **Don't hand-write JSON-LD strings** — Use the utils/seo builders so ids, url resolution and required fields stay consistent, and let JsonLd handle escaping.
- **Don't mark up invisible content** — Structured data must describe content visible on the page. FAQ/Article markup for hidden or unrelated content can earn a manual action.

## Accessibility

- **Script semantics**: Renders a non-executable script element; assistive tech ignores it. It adds no accessibility tree nodes.
- **Injection safety**: Stringifies with `<` escaped to a unicode escape, so values containing markup cannot break out of the script element

## Composition

- Compose with **Prose** — Article/TechArticle JSON-LD should describe Prose-rendered article content
  
  ```tsx
  <><JsonLd data={articleJsonLd({...})} /><Prose>...</Prose></>
  ```
- Related: Prose, Breadcrumb

