npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@slate-serializers/react

v2.5.3

Published

Render Slate JSON as React elements using the same configuration shape as slateToHtml.

Readme

@slate-serializers/react

Render Slate JSON as React elements using the same mental model as slateToHtml.

Live examples: SlateToReact docs on the demo site (source).

Table of contents

Install

npm install @slate-serializers/react
# peer: react, react-dom (same range as your app)

Usage

import { SlateToReact } from '@slate-serializers/react'

const value = [
  {
    type: 'h1',
    children: [{ text: 'Heading' }],
  },
]

export function Example() {
  return <SlateToReact node={value} />
}
  • node — Slate value as an array of top-level blocks (same shape you pass to other serializers in this repo).
  • config — optional; defaults to slateToReactConfig (aligned with the Slate serialization guide).

Payload CMS

import { SlateToReact, payloadSlateToReactConfig } from '@slate-serializers/react'

<SlateToReact node={value} config={payloadSlateToReactConfig} />

Configuration (flat API)

SlateToReact uses a single flat object for configuration: the same top-level keys as slateToHtml / SlateToDomConfig (markMap, elementMap, elementAttributeTransform, defaultTag, entity / line-break options, etc.), plus:

| Key | Role in React | | --- | --- | | elementTransforms | Required in the type. Each entry maps a Slate block type to a function that returns a React node (JSX or React.createElement). Replaces / augments elementMap for those types. | | markMap | Maps Slate leaf properties to tag names for inline marks. Those tags are turned into DOM-like nodes, then into React. |

SlateToReactConfig extends the DOM BaseConfig and types elementTransforms / optional markTransforms as returning ReactNode, not domhandler Elements.

markTransforms vs markMap

Internally, SlateToReact runs the shared DOM converter with DOM elementTransforms / markTransforms cleared so that block-level output is driven only by your React elementTransforms. Inline marks use markMap (and the default DOM behavior for simple tags), not the DOM serializer’s markTransforms.

  • For custom per-mark DOM logic (returning new Element(...)), use slateToHtml from @slate-serializers/html.
  • For React output, prefer markMap and, where needed, custom elementTransforms for blocks.

See the demo section “Custom DOM markTransforms…” for a concrete explanation.

Example: custom block component

import { type SlateToReactConfig, SlateToReact, slateToReactConfig } from '@slate-serializers/react'

const config: SlateToReactConfig = {
  ...slateToReactConfig,
  elementTransforms: {
    ...slateToReactConfig.elementTransforms,
    callout: ({ children }) => <aside className="callout">{children}</aside>,
  },
}

<SlateToReact node={value} config={config} />

Relationship to slateToHtml

| | slateToHtml | SlateToReact | | --- | --- | --- | | Output | HTML string | React tree | | elementTransforms | Returns domhandler Element (use import { Element } from '@slate-serializers/dom') | Returns ReactNode | | Shared options | markMap, elementMap, encoding flags, etc. | Same keys, one config object |

Engineering

For parser choices, whitespace, and compatibility, see Engineering decisions.

Repo layout

This package lives in the slate-serializers monorepo. Issue tracker: slate-serializers on GitHub.