Installations
npm install @mdx-js/node-loader
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
23.0.0
NPM Version
10.9.0
Score
66.6
Supply Chain
97.7
Quality
81.4
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
64,252
Last Day
69
Last Week
368
Last Month
1,962
Last Year
34,667
GitHub Statistics
MIT License
18,091 Stars
1,752 Commits
1,147 Forks
88 Watchers
6 Branches
190 Contributors
Updated on Feb 21, 2025
Sponsor this package
Package Meta Information
Latest Version
3.1.0
Package Id
@mdx-js/node-loader@3.1.0
Unpacked Size
14.24 kB
Size
5.62 kB
File Count
15
NPM Version
10.9.0
Node Version
23.0.0
Published on
Oct 18, 2024
Total Downloads
Cumulative downloads
Total Downloads
64,252
Last Day
25.5%
69
Compared to previous day
Last Week
13.9%
368
Compared to previous week
Last Month
14.3%
1,962
Compared to previous month
Last Year
52.6%
34,667
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
@mdx-js/node-loader
Node.js hooks (also knows as loaders) for MDX.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Security
- Contribute
- License
What is this?
This package contains Node.js hooks to add support for importing MDX files. Node Customization Hooks are currently a release candidate.
When should I use this?
This integration is useful if you’re using Node and want to import MDX files from the file system.
If you’re using a bundler (webpack, Rollup, esbuild), or a site builder (Next.js) or build system (Vite) which comes with a bundler, you can instead another integration: see § Integrations.
Install
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install @mdx-js/node-loader
Use
Say we have an MDX document, example.mdx
:
1export function Thing() { 2 return <>World!</> 3} 4 5# Hello, <Thing />
…and our module example.js
looks as follows:
1import {renderToStaticMarkup} from 'react-dom/server' 2import React from 'react' 3import Content from './example.mdx' 4 5console.log(renderToStaticMarkup(React.createElement(Content)))
…then running with:
1node --loader=@mdx-js/node-loader example.js
…yields:
1<h1>Hello, World!</h1>
Note: if you use Node 18 and lower, then you can ignore the following warning:
1(node:20718) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any > time 2(Use `node --trace-warnings ...` to show where the warning was created)
Note: if you use Node 20 and higher, then you get the following warning:
1(node:20908) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use > `register()`: 2--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from > "node:url"; register("%40mdx-js/node-loader", pathToFileURL("./"));'
You can solve that by adding a
register.js
file:1import {register} from 'node:module' 2 3register('@mdx-js/node-loader', import.meta.url)
…and running
node --import ./register.js example.js
instead.
API
This package export the identifiers createLoader
and
load
.
There is no default export.
createLoader(options?)
Create Node.js hooks to handle markdown and MDX.
Parameters
options
(Options
, optional) — configuration
Returns
Node.js hooks ({load}
).
load
Load file:
URLs to MD(X) files.
See load
in Node.js docs for more info.
Options
Configuration (TypeScript type).
Options are the same as CompileOptions
from @mdx-js/mdx
exception that the development
option is supported based on whether you
run Node with --conditions development
.
You cannot pass it manually.
Types
This package is fully typed with TypeScript.
It exports the additional type Options
.
See § Types on our website for information.
Compatibility
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, @mdx-js/node-loader@^3
,
compatible with Node.js 16.
Security
See § Security on our website for information.
Contribute
See § Contribute on our website for ways to get started. See § Support for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
License

No vulnerabilities found.
Reason
7 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/mdx-js/.github/security.md:1
- Info: Found linked content: github.com/mdx-js/.github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/mdx-js/.github/security.md:1
- Info: Found text in security policy: github.com/mdx-js/.github/security.md:1
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:5: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/bb.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/website.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/website.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/website.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/website.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/website.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/website.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/website.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/mdx-js/mdx/website.yml/main?enable=pin
- Info: 0 out of 8 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 3 out of 3 npmCommand dependencies pinned
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/website.yml:7
- Warn: no topLevel permission defined: .github/workflows/bb.yml:1
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Warn: no topLevel permission defined: .github/workflows/website.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Score
5.2
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More