Rehype tutorials

Focused, task-based lessons. Each one builds a working pipeline, and every code sample was executed with Node.js to capture the output shown.

Rehype Parse and Stringify Explained

Intermediate

The parser and serializer at the heart of rehype: fragments, parse errors, and the options that change the output.

Updated 2 min read

Sanitize HTML safely with rehype-sanitize

Intermediate

Use rehype-sanitize to neutralize XSS in user content: schemas, plugin order, DOM clobbering and the mistakes to avoid.

Updated 2 min read

Syntax highlighting with rehype-highlight

Intermediate

Highlight code at build time from HTML or Markdown, style it with a theme, keep bundles small and stay safe with sanitizing.

Updated 1 min read

Format and minify HTML with rehype

Beginner

Pretty-print HTML with rehype-format for humans and minify it with rehype-preset-minify for production, in code or from the CLI.

Updated 2 min read

Build Your First Rehype Plugin

Intermediate

Write two real plugins: one that changes the tree (lazy images) and one that reports problems (missing alt text).

Updated 2 min read

Using rehype plugins with MDX and Next.js

Intermediate

Pass rehype plugins to MDX and to Next.js through the rehypePlugins option, including the Turbopack-compatible string syntax.

Updated 2 min read

Prefer opinion and background? Read the blog.

Use ↑ ↓ to move, Enter to open.