# remark-mdx-frontmatter

> A remark plugin for converting frontmatter metadata into MDX exports

Latest version **6.0.0** (published 2026-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install remark-mdx-frontmatter
pnpm add remark-mdx-frontmatter
yarn add remark-mdx-frontmatter
bun add remark-mdx-frontmatter
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-09-23 |
| First published | 2021-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 146 |
| Author | Remco Haszing |
| Maintainers | remcohaszing |
| Keywords | frontmatter, markdown, markdown-frontmatter, mdast, mdx, remark, remark-plugin, toml, unified, yaml |

## Links

- npm: https://www.npmjs.com/package/remark-mdx-frontmatter
- Repository: https://github.com/remcohaszing/remark-mdx-frontmatter
- Homepage: https://github.com/remcohaszing/remark-mdx-frontmatter#readme
- Issues: https://github.com/remcohaszing/remark-mdx-frontmatter/issues
- Funding: https://github.com/sponsors/remcohaszing
- npm.io page: https://npm.io/package/remark-mdx-frontmatter

## Dependencies (6)

- [yaml](https://npm.io/package/yaml.md) ^2.0.0
- [unified](https://npm.io/package/unified.md) ^11.0.0
- [smol-toml](https://npm.io/package/smol-toml.md) ^1.0.0
- [@types/mdast](https://npm.io/package/@types/mdast.md) ^4.0.0
- [unist-util-mdx-define](https://npm.io/package/unist-util-mdx-define.md) ^1.0.0
- [estree-util-value-to-estree](https://npm.io/package/estree-util-value-to-estree.md) ^3.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 6.0.0 (latest) — 2026-09-23
- 5.2.0 — 2025-06-04
- 5.1.0 — 2025-03-22
- 5.0.0 — 2024-06-21
- 4.0.0 — 2023-10-26
- 3.0.0 — 2023-04-23
- 2.1.1 — 2022-10-27
- 2.0.3 — 2022-07-21
- 2.0.2 — 2022-07-09
- 2.0.1 — 2022-07-09
- 2.0.0 — 2022-07-09
- 1.1.1 — 2021-11-15
- 1.1.0 — 2021-11-07
- 1.0.1 — 2021-03-14
- 1.0.0 — 2021-03-07

## README

# remark-mdx-frontmatter

[![github actions](https://github.com/remcohaszing/remark-mdx-frontmatter/actions/workflows/ci.yaml/badge.svg)](https://github.com/remcohaszing/remark-mdx-frontmatter/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/remcohaszing/remark-mdx-frontmatter/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/remark-mdx-frontmatter)
[![npm version](https://img.shields.io/npm/v/remark-mdx-frontmatter)](https://www.npmjs.com/package/remark-mdx-frontmatter)
[![npm downloads](https://img.shields.io/npm/dm/remark-mdx-frontmatter)](https://www.npmjs.com/package/remark-mdx-frontmatter)

A [remark](https://remark.js.org) plugin for converting frontmatter metadata into MDX exports

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
  - [Options](#options)
- [Compatibility](#compatibility)
- [License](#license)

## Installation

This package depends on the AST output by
[remark-frontmatter](https://github.com/remarkjs/remark-frontmatter)

```sh
npm install remark-frontmatter remark-mdx-frontmatter
```

## Usage

This remark plugin takes frontmatter content, and outputs it as JavaScript exports. Both YAML and
TOML frontmatter data are supported.

For example, given a file named `example.mdx` with the following contents:

```mdx
---
hello: frontmatter
---

Rest of document
```

The following script:

```js
import { readFile } from 'node:fs/promises'

import { compile } from '@mdx-js/mdx'
import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'

const { value } = await compile(await readFile('example.mdx'), {
  jsx: true,
  remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter]
})
console.log(value)
```

Roughly yields:

```jsx
export const frontmatter = {
  hello: 'frontmatter'
}

export default function MDXContent() {
  return <p>Rest of document</p>
}
```

## API

The default export is a [remark](https://remark.js.org) plugin.

### Options

- `default`: The default value to export if no frontmatter data is found. (Default: `undefined`).
- `name`: The identifier name of the variable the frontmatter data is assigned to. (Default:
  `frontmatter`).
- `parsers`: A mapping A mapping of node types to parsers. Each key represents a frontmatter node
  type. The value is a function that accepts the frontmatter data as a string, and returns the
  parsed data. By default `yaml` nodes will be parsed using [`yaml`](https://github.com/eemeli/yaml)
  and `toml` nodes using [`toml`](https://github.com/BinaryMuse/toml-node).

In addition it supports `unist-util-mdx-define`
[options](https://github.com/remcohaszing/unist-util-mdx-define#options).

## Compatibility

This project is compatible with Node.js 22 or greater.

## License

[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)

---
_Source: https://npm.io/package/remark-mdx-frontmatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
