Dev.to WebDev 🛠 Dev 👁 2 📖 2 min read

Moving your remark/rehype plugins to Astro 7 (Sätteri)

Astro 7 changed the default markdown processor. It used to be unified, the remark/rehype pipeline most of us have been piling plugins onto for years. Now it's Sätteri, a markdown/MDX engine written in Rust. The speed is

Astro 7 changed the default markdown processor. It used to be unified, the remark/rehype pipeline most of us have been piling plugins onto for years. Now it's Sätteri, a markdown/MDX engine written in Rust.

The speed is real. Astro's own docs build got over a minute faster. The catch is that Sätteri has its own AST and its own plugin API, so none of your remark or rehype plugins run anymore.

You can opt back into unified() with @astrojs/markdown-remark, and plenty of sites have. But then you skip the speed-up and keep an extra dependency around.

I went through my own plugin list, and then the most downloaded ones on npm, and sorted them into three groups.

1. Delete it, Sätteri already does it

More of these than I expected:

Plugin Sätteri
remark-gfm features.gfm (on by default)
remark-frontmatter features.frontmatter (on by default)
remark-math features.math (parsing only)
remark-directive features.directive
remark-smartypants features.smartPunctuation
remark-wiki-link features.wikilinks
remark-sup / remark-sub features.superscript / features.subscript
remark-definition-list features.definitionList
remark-parse, remark-rehype, rehype-stringify... the pipeline itself

If your config is mostly this list, you can migrate today and remove a lot of dependencies.

2. Swap it for a port

For the rest I wrote ports, published as separate packages so you only install what you use:

Was Now
rehype-slug satteri-slug
rehype-autolink-headings satteri-autolink-headings
rehype-katex satteri-katex
rehype-mathjax satteri-mathjax
rehype-sanitize satteri-sanitize
remark-breaks satteri-breaks
remark-github satteri-github
remark-mdx-frontmatter satteri-mdx-frontmatter
remark-validate-links satteri-validate-links
rehype-citation satteri-citation

Options are kept the same as the originals wherever it made sense. Each package's tests run the same markdown through the original plugin and the port and compare the HTML, so switching shouldn't change your output.

A typical config ends up like this:

// astro.config.mjs
import { defineConfig } from "astro/config";
import { satteri } from "@astrojs/markdown-satteri";
import { satteriSlug } from "satteri-slug";
import { satteriAutolinkHeadings } from "satteri-autolink-headings";
import { satteriKatex } from "satteri-katex";

export default defineConfig({
  markdown: {
    processor: satteri({
      features: { math: true },
      mdastPlugins: [satteriKatex()],
      hastPlugins: [
        satteriSlug(),
        satteriAutolinkHeadings({ behavior: "wrap" }),
      ],
    }),
  },
});

3. Gotchas I hit

Heading ids show up too late. Astro's Sätteri processor adds heading ids with its own plugin, but it adds that plugin after yours. So anything that needs ids (autolink, a table of contents, scroll spy) sees headings with no id and does nothing. No error, the anchors just aren't there. Put satteriSlug() first in hastPlugins. It uses github-slugger, so the ids match what rehype-slug gave you.

Sanitize eats your math. If you sanitize and render math, the default allowlist strips KaTeX/MathJax markup. You have to widen it. The satteri-sanitize README has the exact config for both renderers.

KaTeX and MathJax don't mix. Both consume the same math nodes, so pick one.

Plugin order is array order. Same as unified, but worth checking after you move things around.

Try it

The example site is a real Astro 7 build, made in CI, using every plugin: satteri-plugins.js.org

Code, docs and issues: github.com/Ashish-CodeJourney/satteri-plugins

If a plugin is keeping you on unified(), open an issue with its name. That's how I'm picking what to port next.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.