Skip to content
// EFFECT DAYS 2026

MarkdownVite unstable

A Vite plugin that compiles imported .md files at build time into document modules, so no parser ships to the browser.

Each module's default export is the encoded document; decode it with Markdown.decodeDocument and render it with Markdown.view. Each module also exports frontmatter: the checked fields when the plugin has a frontmatter schema and the file has a frontmatter block, and undefined otherwise. Source outside the vocabulary fails the build with the construct and its line.

Add effect/ui/html/MarkdownContent to compilerOptions.types for the *.md module types.

Example Configuring the plugin

import { markdown } from "effect/ui/html/MarkdownVite"
import { Schema } from "effect"
// vite.config.ts: export default { plugins: [plugin] }
const plugin = markdown({
frontmatter: Schema.Struct({ title: Schema.String }),
islands: { Counter: Schema.Struct({ label: Schema.optionalKey(Schema.String) }) }
})
const compiled = plugin.transform("---\ntitle: Hello\n---\n\n::Counter", "/posts/hello.md")
compiled?.code.split("\n")[1] // => 'export const frontmatter = {"title":"Hello"}'
3 exports Since v4.2.0 Source

Constructors

markdown

unstable
Since v4.2.0

Creates the Vite plugin. It transforms module ids ending in .md and leaves every other module untouched. Options are checked once, here.

Signature

declare function markdown(options: Options): Plugin

Models

Plugin

interface unstable
Since v4.2.0

The subset of a Vite plugin that markdown returns. It is assignable to Vite's Plugin without importing vite.

Signature

interface Plugin {
readonly name: string;
readonly transform: (source: string, id: string) => TransformResult | undefined;
}

TransformResult

interface unstable
Since v4.2.0

The module code a .md file compiles to.

Signature

interface TransformResult {
readonly code: string;
readonly map: null;
}