MDX
Compiles and renders a string of MDX content.
Security
This component evaluates JavaScript. Always sanitize user-provided content before passing it to the MDX
component. This includes sanitizing value
, components
, and dependencies
.
Failing to do so puts you at risk of a cross-site scripting (XSS) attack. See the MDX security documentation for more information.
Prefer the Markdown
component if possible for rendering untrusted content as it does not evaluate JavaScript and is therefore safe by default.
Examples
Basic
View SourceHello World
import { MDX } from 'renoun/components' export function Basic() { return <MDX># Hello World</MDX> }
API Reference
MDXProps
MDXProps
Properties
children *
string
The MDX content to render.
components
MDXComponents
Additional components to use or a function that creates them.
dependencies
Record<string, any>
An object of external dependencies that will be available to the MDX source code.
remarkPlugins
null | PluggableList
Remark plugins to use. See PluggableList for more info.
rehypePlugins
null | PluggableList
Rehype plugins to use. See PluggableList for more info.
baseUrl
string
Base URL to resolve imports and named exports from (e.g. import.meta.url
)
MDX
({ children, components, dependencies, remarkPlugins, rehypePlugins, baseUrl, }: MDXProps) => Promise<React.JSX.Element>
Compiles and renders a string of MDX content.
Parameters
MDXProps