Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
sanity-io avatar

Portable Text Serialization

  • 1.5k installs
  • 171 repo stars
  • Updated July 29, 2026
  • sanity-io/agent-toolkit

portable-text-serialization is an agent skill for render and serialize portable text to react, svelte, vue, astro, html, markdown, and plain text. use when implementing portable text rendering in any frontend framework,.

About

The portable-text-serialization skill is designed for render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework,. Portable Text Serialization Render Portable Text content across frameworks using the @portabletext/* library family. Each library follows the same component-mapping pattern: you provide a components object that maps PT node types to framework-specific renderers. Invoke when the user implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, extracting plain text from Portable Text, or troubleshooting rendering issues with marks, blocks, lists, or custom types.

  • Decorators: string values in marks[] like "strong", "em", "underline", "code".
  • Annotations: keys in marks[] referencing entries in markDefs[] (e.g., links, internal references).
  • React / Next.js: rules/react.md — @portabletext/react or next-sanity.
  • Svelte / SvelteKit: rules/svelte.md — @portabletext/svelte.
  • Vue / Nuxt: rules/vue.md — @portabletext/vue.

Portable Text Serialization by the numbers

  • 1,507 all-time installs (skills.sh)
  • +91 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #244 of 1,880 Design & UI/UX skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 2, 2026 (Skillselion catalog sync)
At a glance

portable-text-serialization capabilities & compatibility

Capabilities
decorators: string values in marks[] like "stron · annotations: keys in marks[] referencing entries · react / next.js: rules/react.md — @portabletext/ · svelte / sveltekit: rules/svelte.md — @portablet
Use cases
frontend
From the docs

What portable-text-serialization says it does

Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework, building c
SKILL.md
Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend f
SKILL.md
npx skills add https://github.com/sanity-io/agent-toolkit --skill portable-text-serialization

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars171
Security audit3 / 3 scanners passed
Last updatedJuly 29, 2026
Repositorysanity-io/agent-toolkit

How do I render and serialize portable text to react, svelte, vue, astro, html, markdown, and plain text. use when implementing portable text rendering in any frontend framework,?

Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework,.

Who is it for?

Developers using portable text serialization workflows documented in SKILL.md.

Skip if: Skip when the task falls outside portable-text-serialization scope or needs a different stack.

When should I use this skill?

User implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, e

What you get

Completed portable-text-serialization workflow with documented commands, files, and expected deliverables.

  • framework serializer components
  • HTML or Markdown conversion output
  • plain-text extraction utility

By the numbers

  • Targets seven output formats: React, Svelte, Vue, Astro, HTML, Markdown, and plain text
  • Skill metadata lists version 1.0.0 with MIT license from Sanity

Files

SKILL.mdMarkdownGitHub ↗

Portable Text Serialization

Render Portable Text content across frameworks using the @portabletext/* library family. Each library follows the same component-mapping pattern: you provide a components object that maps PT node types to framework-specific renderers.

Portable Text Structure (Quick Reference)

PT is an array of blocks. Each block has _type, optional style, children (spans), markDefs, listItem, and level.

Root array
├── block (_type: "block")
│   ├── style: "normal" | "h1" | "h2" | "blockquote" | ...
│   ├── children: [span, span, ...]
│   │   └── span: { _type: "span", text: "...", marks: ["strong", "<markDefKey>"] }
│   ├── markDefs: [{ _key, _type: "link", href: "..." }, ...]
│   ├── listItem: "bullet" | "number" (optional)
│   └── level: 1, 2, 3... (optional, for nested lists)
├── custom block (_type: "image" | "code" | any custom type)
└── ...more blocks

Marks come in two forms:

  • Decorators: string values in marks[] like "strong", "em", "underline", "code"
  • Annotations: keys in marks[] referencing entries in markDefs[] (e.g., links, internal references)

Component Mapping Pattern (All Frameworks)

Every @portabletext/* library accepts a components object with these keys:

KeyRendersProps/Data
typesCustom block/inline types (image, code, CTA)value (the block data)
marksDecorators + annotationschildren + value (mark data)
blockBlock styles (h1, normal, blockquote)children
listList wrappers (ul, ol)children
listItemList itemschildren
hardBreakLine breaks within a block

Framework-Specific Rules

Read the rule file matching your framework:

  • React / Next.js: rules/react.md@portabletext/react or next-sanity
  • Svelte / SvelteKit: rules/svelte.md@portabletext/svelte
  • Vue / Nuxt: rules/vue.md@portabletext/vue
  • Astro: rules/astro.mdastro-portabletext
  • HTML (server-side): rules/html.md@portabletext/to-html
  • Markdown: rules/markdown.md@portabletext/markdown
  • Plain text extraction: rules/plain-text.md@portabletext/toolkit

Additional Community Serializers

These are listed on portabletext.org but don't have dedicated rule files:

TargetPackage
React Native@portabletext/react-native-portabletext
React PDF@portabletext/react-pdf-portabletext
Solidsolid-portabletext
Qwikportabletext-qwik
Shopify Liquidportable-text-to-liquid
PHPsanity-php (SanityBlockContent class)
Pythonportabletext-html
C# / .NETdotnet-portable-text
Dart / Flutterflutter_sanity_portable_text

Common Patterns (All Frameworks)

Custom Types Need Explicit Components

PT renderers only handle standard blocks by default. Custom types (image, code, callToAction, etc.) require explicit component mappings — they won't render otherwise.

Keep Components Object Stable

In React/Vue, define components outside the render function or memoize it. Recreating on every render causes unnecessary re-renders.

Handle Missing Components Gracefully

All libraries accept onMissingComponent to control behavior when encountering unknown types:

  • false — suppress warnings
  • Custom function — log or report

Querying PT with GROQ

Always expand references inside custom blocks:

body[]{
  ...,
  _type == "image" => {
    ...,
    asset->
  },
  markDefs[]{
    ...,
    _type == "internalLink" => {
      ...,
      "slug": @.reference->slug.current
    }
  }
}

Related skills

How it compares

Pick portable-text-serialization for Sanity Portable Text JSON; generic Markdown renderers cannot handle custom block types and mark decorators.

FAQ

What does portable-text-serialization do?

Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework,.

When should I use portable-text-serialization?

User implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, extracting plain text from Portable Text, or troubleshooting

Is portable-text-serialization safe to install?

Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.