Open-source project
pngwn/MDsveX avatar
pngwn/MDsveX

MDsveX: Markdown as a Svelte preprocessor

A markdown preprocessor for Svelte.

3,062 stars129 forksJavaScriptMIT

At a glance

What is it?
MDsveX turns .md files into Svelte components at build time, so you can mix Markdown prose with Svelte syntax. It is a small, single-purpose preprocessor, and the 1.0.0-next.0 releases show the project is mid-rewrite rather than settled.
Who is it for?
Adopt MDsveX if you write content-heavy pages in Svelte or SvelteKit and want Markdown files that can still import components and use Svelte expressions. Do not adopt it if you need a stable, frozen API today: the newest published line is 1.0.0-next.0, and the monorepo is being reorganized around svast, svelte-parse and svast-stringify.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 3, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What MDsveX solves, and who it is for

Svelte has no built-in story for authoring long-form prose. You can write markup by hand, or you can keep content in Markdown and lose the ability to drop a live component into the middle of a paragraph. MDsveX sits in that gap. The repository describes it as "A markdown preprocessor for Svelte. Markdown in Svelte." The unit of work is a .md file that Svelte's build pipeline treats as a component.

The audience is narrow and specific. It is for people building SvelteKit sites where blog posts, documentation pages or changelogs are stored as Markdown but still need interactive or styled pieces inside them. A docs site that wants a live code sample, or a blog post that wants a chart component, is the natural fit. It is not a general Markdown pipeline and it is not a static site generator. It does not decide your routes, your data loading or your output format. Those remain SvelteKit's job.

That narrowness is the point. If you only need Markdown rendered to HTML at request time, a runtime Markdown library is simpler, because nothing has to be compiled ahead of time. MDsveX earns its place only when the Markdown has to participate in the component graph.

How the preprocessor pipeline is put together

The repository is a pnpm monorepo, and the package list in the README is the clearest description of the architecture. Alongside mdsvex itself there are svelte-parse, svast, svast-stringify and svast-utils. Read together, they describe a parse-transform-print pipeline. svelte-parse is documented as generating "a svast AST from a Svelte components". svast is "An AST specification with accompanying TypeScript definitions". svast-stringify turns "a svast AST into a Svelte component". svast-utils holds helpers for walking that tree.

So the flow is: a Markdown file is parsed, the embedded Svelte fragments are parsed into a Svelte-specific AST, the two are combined, and the result is printed back out as a Svelte component that the compiler accepts. Keeping a Svelte-aware AST in the middle is what allows the tool to understand Svelte syntax inside Markdown rather than treating it as opaque text. A generic Markdown-to-HTML converter cannot do this, because by the time it has produced HTML the Svelte expressions are already gone.

The cost of that design is a wider dependency surface. The root package.json lists Rollup plugins, tslib and playwright among its dependencies, and the workspace is pinned to pnpm 9.1.4 through both engines and packageManager. Anyone contributing to the preprocessor is working inside that toolchain, not in a single-file project. The README also states that the repo uses changesets for changelogs and versioning, and that "All pull requests need an accompanying changeset file", with documentation-site PRs exempt. That is a real contribution rule, not a formality.

Installing MDsveX and rendering a first Markdown page

The README points readers to the per-package readmes for detail and to mdsvex.com for documentation, and the monorepo layout confirms the main package lives under packages/mdsvex. The published package name is mdsvex. The root README does not include install commands, so take the exact package manager invocation from the mdsvex package readme or the documentation site rather than guessing.

The pieces you need to confirm before writing code are the preprocessor options and the file extensions you want treated as components. The repository's own test and build scripts show the toolchain it is developed against: the root package.json defines scripts including `test`, `test:e2e` and `release`, and the workspace pins pnpm through the engines field:

json
"engines": {
  "pnpm": "^9.1.4"
},
"packageManager": "[email protected]"

That is the environment the monorepo expects. The wiring of the preprocessor itself into a Svelte config is documented in the mdsvex package readme, which the root README links as `packages/mdsvex`; check there for the option names and for any layout or remark/rehype hooks, since those are not described in the root README.

The version you install matters more than usual here. The most recent releases listed are [email protected], @mdsvex/[email protected] and @mdsvex/[email protected], all published on 2026-09-20. Those are prereleases. The root package.json still reads version 0.8.5, which reflects the older line. If you install without pinning, you may land on either side of that split.

Where MDsveX stops being the right tool

The clearest limitation is version churn. The 1.0.0-next.0 prereleases and the presence of new supporting packages suggest the internals are being reworked, and the root package.json version of 0.8.5 does not describe what is on npm today. If your project needs a frozen preprocessor API with a long support window, that mismatch is a genuine risk. Pin exact versions and read the changesets when you upgrade.

A second boundary is scope. MDsveX is a preprocessor, not a content system. It does not provide routing, frontmatter-driven page generation, pagination, RSS or an image pipeline. People searching for how MDsveX handles images should note that the root README says nothing about image handling at all. Any image behaviour comes from the surrounding SvelteKit setup or from Markdown and rehype behaviour configured elsewhere. Treating MDsveX as a batteries-included blog engine will lead to building those parts yourself.

Third, the tool is tied to Svelte. The search interest around MDsveX and Svelte 5 points at a real question, and the root README does not state which Svelte major versions are supported. That is something to verify against the package readme and the release notes before adopting, because a preprocessor that emits component code is sensitive to the compiler version it targets. If your stack is React or Vue, MDsveX is simply not applicable.

MDsveX compared with a runtime Markdown renderer

The obvious alternative for the same job is rendering Markdown at runtime inside a Svelte component, using a JavaScript Markdown parser plus a sanitizer. The difference in approach is where the work happens. A runtime renderer takes a string and produces HTML in the browser or on the server; MDsveX takes a file and produces a component during the build.

That difference has practical consequences. Runtime rendering keeps the Markdown as data, so content can come from a database or a CMS without a rebuild, and the toolchain stays small. It also means the Markdown cannot contain Svelte components or Svelte expressions, because a generic parser has no concept of them, and you generally need to sanitize output you did not author. MDsveX inverts both properties: content is compiled ahead of time and cannot change without a rebuild, but the Markdown can import and use components, and there is no HTML sanitization step for content you control.

A second alternative is keeping prose in .svelte files and accepting the markup overhead. That avoids a preprocessor dependency entirely and keeps everything in one language. It becomes painful once documents get long or when non-developers need to edit them. The trade is authoring comfort against build complexity, and MDsveX only wins when the authoring side matters enough to justify the extra package.

Maintenance, licence and the cost of upgrading

The repository is not archived, and the last push was on 2026-09-22, two days before the date used for this assessment. The 1.0.0-next.0 prereleases landed on 2026-09-20. Whatever else is true, this is not an abandoned codebase, and the release cadence is recent. The caveat is that recent activity is concentrated in prerelease versions, so "actively developed" describes the repository rather than the version you will most likely install.

Upgrade cost is governed by the changesets workflow the README describes. Every pull request carries a changeset file, which means changelogs are generated per package. In a monorepo where mdsvex, @mdsvex/typescript-plugin and @mdsvex/source-map version independently, you should expect to track more than one package when the AST layer changes. Pinning exact versions and reading the generated changelog for each bump is the practical way to keep upgrades cheap.

The licence is MIT, declared in the root package.json and present as a LICENSE file at the repository root. MIT permits commercial use, modification and redistribution provided the copyright notice and permission notice are retained. That is a permissive arrangement, and it is the same licence the project has carried through the 0.8.5 line into the prereleases. This is a description of the licence text, not legal advice; if your organisation has specific obligations around attribution in distributed artifacts, have counsel review the LICENSE file as shipped.

Editorial conclusion

Adopt MDsveX if you write content-heavy pages in Svelte or SvelteKit and want Markdown files that can still import components and use Svelte expressions. Do not adopt it if you need a stable, frozen API today: the newest published line is 1.0.0-next.0, and the monorepo is being reorganized around svast, svelte-parse and svast-stringify. Before committing, check the packages/mdsvex readme for the current preprocessor options, confirm which Svelte major your toolchain targets, and pin the exact version in package.json rather than tracking a range.

Frequently asked questions

How do you use MDsveX in a Svelte project?

You add it as a preprocessor and list .md in the extensions array so Svelte treats Markdown files as components. The exact option names for layout, remark and rehype hooks are documented in the mdsvex package readme and on mdsvex.com rather than in the root README.

Is there a VS Code extension for MDsveX?

The repository does not mention a VS Code extension. The packages listed in the README are the documentation site, mdsvex, svelte-parse, svast, svast-stringify and svast-utils, so editor tooling is not part of what the material describes.

What is MDsveX?

It is a Markdown preprocessor for Svelte, described in the README as "A markdown preprocessor for Svelte. Markdown in Svelte." It compiles Markdown files into Svelte components during the build.

Does MDsveX work with SvelteKit?

MDsveX is a Svelte preprocessor, so it plugs into the Svelte compilation step that SvelteKit runs. The root README does not document SvelteKit-specific setup, so configuration details belong to the mdsvex package readme and the documentation site.

Which version of MDsveX should I install?

The most recent releases listed are [email protected] and two supporting @mdsvex packages, all published on 2026-09-20, while the root package.json still reads version 0.8.5. Pin an exact version rather than a range so you know which line you are on.

Official sources

  1. License: MIT
  2. pngwn/MDsveX on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/pngwn-mdsvex.svg)](https://hysenlabs.com/projects/pngwn-mdsvex)