MDXRenderer

Compiles and renders a string of MDX content.

Security

Always sanitize user-provided content before passing it to MDXRenderer. 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.

Examples

  • Hello World

    import { MDXRenderer } from 'renoun/components'
    
    export function Basic() {
      return <MDXRenderer># Hello World</MDXRenderer>
    }

API Reference

MDXRenderer

({ children, components, dependencies, remarkPlugins, rehypePlugins, baseUrl, }: MDXRendererProps) => Promise<React.JSX.Element>

Compiles and renders a string of MDX content.

Parameters
MDXRendererProps
Returns
Promise<Element>

MDXRendererProps

MDXRendererProps
Properties

children *

string

The MDX content to render.

components

MDXComponents | undefined

Additional components to use or a function that creates them.

dependencies

Record<string, any> | undefined

An object of external dependencies that will be available to the MDX source code.

remarkPlugins

PluggableList | null | undefined

Remark plugins to use. See PluggableList for more info.

rehypePlugins

PluggableList | null | undefined

Rehype plugins to use. See PluggableList for more info.

baseUrl

string | undefined

Base URL to resolve imports and named exports from (e.g. import.meta.url)